Java Server Pages (JSP) allow embedding Java code within HTML pages to create dynamic web content. JSP pages are compiled to servlets at runtime to generate the response. Key components of JSP include scripting elements to add Java code, implicit objects to access HTTP session and request attributes, directives to configure page properties, and actions to include pages and forward requests. JSP provides a simplified model to create servlets without having to extend base classes or write HTTP specific code.
Slides from GeoDjango talk given by Eric Palakovich Carr. Last given in Washington, D.C. for django-district meetup on July 27th, 2011.
http://www.meetup.com/django-district/events/16015696/
Source code hosted on github:
https://github.com/bigsassy/geodjango_talk
Slides from GeoDjango talk given by Eric Palakovich Carr. Last given in Washington, D.C. for django-district meetup on July 27th, 2011.
http://www.meetup.com/django-district/events/16015696/
Source code hosted on github:
https://github.com/bigsassy/geodjango_talk
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCalderaLearn
The WordPress REST API combined with a JavaScript MVC framework opens up new possibilities for better, more intuitive interfaces that solve scaling and other challenges. In this workshop we will use AngularJS, the best — because we said so — and the WordPress REST API to create custom applications. First we will walk through creating custom API routes and endpoints to interact with your data, followed by two unique ways to use AngularJS to create better interfaces for your projects. This will include a decoupled front-end and single page web app as a plugin interface.
HTML5 is all the rage with the cool kids, and although there's a lot of focus on the new language, there's lots of interesting new JavaScript APIs both in the HTML5 spec and separated out. This presentation will take you through demos and code behind the new JavaScript APIs, and explore where these features can be used
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
Slide links:
- https://lumberjack.rareloop.com
- https://docs.lumberjack.rareloop.com
- https://github.com/Rareloop/lumberjack-bedrock-installer
- https://github.com/Rareloop/lumberjack
- https://github.com/Rareloop/lumberjack-validation
- https://github.com/Rareloop/hatchet
- rareloop.com/careers
- https://www.rareloop.com/posts/comparing-modern-mvc-wordpress-frameworks/
- https://lizkeogh.com/2017/08/31/reflecting-reality/amp
- https://www.youtube.com/watch?v=uQUxJObxTUs
- https://www.upstatement.com/timber
- https://roots.io/bedrock
---
Often WordPress themes are not easy to change, maintain or fun to work on. This can rule WordPress out as a viable option for bespoke, non-trivial websites.
In this talk we’ll dive into how this happens & look at how we can benefit from software engineering techniques to help make your code easier to change. I’ll also show how using Lumberjack, a powerful MVC framework built on Timber, can be used to power-up your themes.
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
What is different about this generation of web applications? A solid development approach must consider latency, throughput, and interactivity demanded by users users across mobile devices, web browsers, and IoT. These applications often use NoSQL to support a flexible data model and easy scalability required for modern development.
A full stack application (composed of Couchbase, WebAPI, Angular2, and ASP.NET/ASP.NET Core) will be demonstrated in this session. The individual parts of a stack may vary, but the overall design is the focus.
Caldera Learn - LoopConf WP API + Angular FTW WorkshopCalderaLearn
The WordPress REST API combined with a JavaScript MVC framework opens up new possibilities for better, more intuitive interfaces that solve scaling and other challenges. In this workshop we will use AngularJS, the best — because we said so — and the WordPress REST API to create custom applications. First we will walk through creating custom API routes and endpoints to interact with your data, followed by two unique ways to use AngularJS to create better interfaces for your projects. This will include a decoupled front-end and single page web app as a plugin interface.
HTML5 is all the rage with the cool kids, and although there's a lot of focus on the new language, there's lots of interesting new JavaScript APIs both in the HTML5 spec and separated out. This presentation will take you through demos and code behind the new JavaScript APIs, and explore where these features can be used
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
Slide links:
- https://lumberjack.rareloop.com
- https://docs.lumberjack.rareloop.com
- https://github.com/Rareloop/lumberjack-bedrock-installer
- https://github.com/Rareloop/lumberjack
- https://github.com/Rareloop/lumberjack-validation
- https://github.com/Rareloop/hatchet
- rareloop.com/careers
- https://www.rareloop.com/posts/comparing-modern-mvc-wordpress-frameworks/
- https://lizkeogh.com/2017/08/31/reflecting-reality/amp
- https://www.youtube.com/watch?v=uQUxJObxTUs
- https://www.upstatement.com/timber
- https://roots.io/bedrock
---
Often WordPress themes are not easy to change, maintain or fun to work on. This can rule WordPress out as a viable option for bespoke, non-trivial websites.
In this talk we’ll dive into how this happens & look at how we can benefit from software engineering techniques to help make your code easier to change. I’ll also show how using Lumberjack, a powerful MVC framework built on Timber, can be used to power-up your themes.
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
What is different about this generation of web applications? A solid development approach must consider latency, throughput, and interactivity demanded by users users across mobile devices, web browsers, and IoT. These applications often use NoSQL to support a flexible data model and easy scalability required for modern development.
A full stack application (composed of Couchbase, WebAPI, Angular2, and ASP.NET/ASP.NET Core) will be demonstrated in this session. The individual parts of a stack may vary, but the overall design is the focus.
This slide is about basics of java servlet and java server page.
A basic example of JSP using multiple directives.
Further information of setting up and using of Apache Tomcat server.
JavaScript, often abbreviated as JS, is a programming language and core techn...MathivananP4
JavaScript, often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. As of 2024, 98.9% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries.
JSP technology is used to create web application just like Servlet technology. It can be thought of as an extension to Servlet because it provides more accuracy.
A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than Servlet because we can separate designing and development. It provides some additional features such as Expression Language, Custom Tags, etc. Extension to Servlet, Easy to maintain, Fast Development: No need to recompile and redeploy, Less code than Servlet
JSP AND XML USING JAVA WITH GET AND POST METHODSbharathiv53
This ppt contains JSP life cycle, Tags, Tomcat, Request String,
User Sessions, Cookies, Session Objects; XML - Tags, Elements,
Attributes, XML with CSS, XML and DTD (Document Type Definition),
XML Schema.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
2. • JSP Fundamentals
• JSP Scripting Elements
• JSP Implicit Objects
• JSP Directives
• JSP Actions
• JSP Example (Loan Calculator)
• Servlets & JSPs together
• Tag Libraries
• Deploying and Running a JSP Application
Topics
3. • Java Server Pages are HTML pages embedded with
snippets of Java code.
– It is an inverse of a Java Servlet
• Four different elements are used in constructing
JSPs
– Scripting Elements
– Implicit Objects
– Directives
– Actions
Java Server Pages (JSP)
Fundamentals
4. • JSPs run in two phases
– Translation Phase
– Execution Phase
• In translation phase JSP
page is compiled into a
servlet
– called JSP Page
Implementation class
• In execution phase the
compliled JSP is
processed
Java Server Pages (JSP)
Architecture
Send
Response
Receive
Request
Load Servlet
Compile JSP
Servlet
Generate JSP
Servlet Source
Parse JSP
JSP Servlet
Current?
JSP Servlet
Loaded?
Generate
Response
Yes
No
NoYes
HTTP Server
JSP Container
Page Compiler Servlet
JSP Page Servlet
5. • There are three kinds of scripting elements
– Declarations
– Scriptlets
– Expressions
Scripting Elements
Types
6. • Declarations are used to define methods & instance
variables
– Do not produce any output that is sent to client
– Embedded in <%! and %> delimiters
Example:
<%!
Public void jspDestroy() {
System.out.println(“JSP Destroyed”);
}
Public void jspInit() {
System.out.println(“JSP Loaded”);
}
int myVar = 123;
%>
– The functions and variables defined are available to the
JSP Page as well as to the servlet in which it is compiled
Declarations
Basics
7. • Used to embed java code in JSP pages.
– Contents of JSP go into _JSPpageservice() method
– Code should comply with syntactical and semantic
constuct of java
– Embedded in <% and %> delimiters
Example:
<%
int x = 5;
int y = 7;
int z = x + y;
%>
Scriptlets
Basics
8. • Used to write dynamic content back to the browser.
– If the output of expression is Java primitive the value is
printed back to the browser
– If the output is an object then the result of calling toString
on the object is output to the browser
– Embedded in <%= and %> delimiters
Example:
– <%=“Fred”+ “ “ + “Flintstone %>
prints “Fred Flintstone” to the browser
– <%=Math.sqrt(100)%>
prints 10 to the browser
Expressions
Basics
9. • Implicit objects provide access to server side objects
– e.g. request, response, session etc.
• There are four scopes of the objects
– Page: Objects can only be accessed in the page where they
are referenced
– Request: Objects can be accessed within all pages that
serve the current request.
(Including the pages that are forwarded to and included in
the original jsp page)
– Session: Objects can be accessed within the JSP pages for
which the objects are defined
– Application: Objects can be accessed by all JSP pages in a
given context
Java Implicit Objects
Scope
10. • request: Reference to the current request
• response: Response to the request
• session: session associated woth current request
• application: Servlet context to which a page belongs
• pageContext: Object to access request, response,
session and application associated with a page
• config: Servlet configuration for the page
• out: Object that writes to the response output stream
• page: instance of the page implementation class (this)
• exception: Available with JSP pages which are error
pages
Java Implicit Objects
List
11. <html>
<head>
<title>Implicit Objects</title>
</head>
<body style="font-family:verdana;font-size:10pt">
<p>
Using Request parameters...<br>
<b>Name:</b> <%= request.getParameter("name") %>
</p>
<p>
<% out.println("This is printed using the out implicit
variable"); %>
</p>
<p>
Storing a string to the session...<br>
<% session.setAttribute("name", "Meeraj"); %>
Retrieving the string from session...<br>
<b>Name:</b> <%= session.getAttribute("name") %>
</p>
Java Implicit Objects
Example
<p>
Storing a string to the application...<br>
<% application.setAttribute("name", "Meeraj"); %>
Retrieving the string from application...<br>
<b>Name:</b>
<%= application.getAttribute("name") %>
</p>
<p>
Storing a string to the page context...<br>
<% pageContext.setAttribute("name", "Meeraj"); %>
Retrieving the string from page context...</br>
<b>Name:</b>
<%= pageContext.getAttribute("name") %>
</p>
</body>
</html>
12. • Save file:
– $TOMCAT_HOME/webapps/jsp/Implicit.jsp
• Access file
– http://localhost:8080/jsp/Implicit.jsp?name=Sanjay
• Results of the execution
Using Request parameters...
Name: sanjay
This is printed using the out implicit variable
Storing a string to the session...
Retrieving the string from session...
Name: Meeraj
Storing a string to the application...
Retrieving the string from application...
Name: Meeraj
Storing a string to the page context...
Retrieving the string from page context...
Name: Meeraj
Example Implicit Objects
Deploy & Run
13. • Messages sent to the JSP container
– Aids the container in page translation
• Used for
– Importing tag libraries
– Import required classes
– Set output buffering options
– Include content from external files
• The jsp specification defines three directives
– Page: provder information about page, such as scripting language that
is used, content type, or buffer size
– Include – used to include the content of external files
– Taglib – used to import custom actions defined in tag libraries
Directives
Basics & Types
14. • Page directive sets page properties used during translation
– JSP Page can have any number of directives
– Import directive can only occur once
– Embedded in <%@ and %> delimiters
• Different directives are
– Language: (Default Java) Defines server side scripting language (e.g. java)
– Extends: Declares the class which the servlet compiled from JSP needs to
extend
– Import: Declares the packages and classes that need to be imported for using
in the java code (comma separated list)
– Session: (Default true) Boolean which says if the session implicit variable is
allowed or not
– Buffer: defines buffer size of the jsp in kilobytes (if set to none no buffering is
done)
Page Directives
Basics & Types
15. • Different directives are (cont’d.)
– autoFlush:When true the buffer is flushed when max buffer size is
reached (if set to false an exception is thrown when buffer exceeds
the limit)
– isThreadSafe: (default true) If false the compiled servlet implements
SingleThreadModel interface
– Info: String returned by the getServletInfo() of the compiled servlet
– errorPage: Defines the relative URI of web resource to which the
response should be forwarded in case of an exception
– contentType: (Default text/html) Defines MIME type for the output
response
– isErrorPage: True for JSP pages that are defined as error pages
– pageEncoding: Defines the character encoding for the jsp page
Page Directives
Types con’t.
17. • Used to insert template text and JSP code during the
translation phase.
– The content of the included file specified by the directive is included
in the including JSP page
• Example
– <%@ include file=“included.jsp” %>
Include Directive
Basics
18. • Processed during the request processing phase.
– As opposed to JSP directives which are processed during translation
• Standard actions should be supported by J2EE compliant web servers
• Custom actions can be created using tag libraries
• The different actions are
– Include action
– Forward action
– Param action
– useBean action
– getProperty action
– setProperty action
– plugIn action
JSP Actions
Basics & Types
19. • Include action used for including resources in a JSP page
– Include directive includes resources in a JSP page at translation time
– Include action includes response of a resource into the response of
the JSP page
– Same as including resources using RequestDispatcher interface
– Changes in the included resource reflected while accessing the page.
– Normally used for including dynamic resources
• Example
– <jsp:include page=“inlcudedPage.jsp”>
– Includes the the output of includedPage.jsp into the page where this is
included.
JSP Actions
Include
20. • Forwards the response to other web specification resources
– Same as forwarding to resources using RequestDispatcher interface
• Forwarded only when content is not committed to other web
application resources
– Otherwise an IllegalStateException is thrown
– Can be avoided by setting a high buffer size for the forwarding jsp
page
• Example
– <jsp:forward page=“Forwarded.html”>
– Forwards the request to Forwarded.html
JSP Actions
Forward
21. • Used in conjunction with Include & Forward actions to
include additional request parameters to the included or
forwarded resource
• Example
<jsp:forward page=“Param2.jsp”>
<jsp:param name=“FirstName” value=“Sanjay”>
</jsp:forward>
– This will result in the forwarded resource having an additional
parameter FirstName with a value of Sanjay
JSP Actions
Param
22. • Creates or finds a Java object with the defined scope.
– Object is also available in the current JSP as a scripting variable
• Syntax:
<jsp:useBean id=“name”
scope=“page | request | session | application”
class=“className” type=“typeName” |
bean=“beanName” type=“typeName” |
type=“typeName” />
– At least one of the type and class attributes must be present
– We can’t specify values for bith the class and bean name.
• Example
<jsp:useBean id=“myName” scope=“request” class=“java.lang.String”>
<% firstName=“Sanjay”; %>
</jsp:useBean>
JSP Actions
useBean
23. • getProperty is used in conjunction with useBean to get property values of
the bean defined by the useBean action
• Example (getProperty)
– <jsp:getProperty name=“myBean” property=“firstName” />
– Name corresponds to the id value in the useBean
– Property refers to the name of the bean property
• setProperty is used to set bean properties
• Example (setProperty)
– <jsp:setProperty name=“myBean” property=“firstName” value=“Sanjay”/>
– Sets the name property of myBean to SanjayExample (setProperty)
– <jsp:setProperty name=“myBean” property=“firstName” param=“fname”/>
– Sets the name property of myBean to the request parameter fname
– <jsp:setProperty name=“myBean” property=“*”>
– Sets property to the corresponding value in request
JSP Actions
get/setProperty
24. • Enables the JSP container to render appropriate HTML (based on the
browser type) to:
– Initiate the download of the Java plugin
– Execution of the specified applet or bean
• plugIn standard action allows the applet to be embedded in a browser
neutral fashion
• Example
<jsp: plugin type=“applet” code=“MyApplet.class” codebase=“/”>
<jsp:params>
<jsp:param name=“myParam” value=“122”/>
</jsp:params>
<jsp:fallback><b>Unable to load applet</b></jsp:fallback>
</jsp:plugin>
JSP Actions
plugIn
28. <%@ page errorPage="error.jsp" %>
<%!
public double calculate(double amount, double
interest, int period) {
if(amount <= 0) {
throw new IllegalArgumentException("Amount
should be greater than 0: " + amount);
}
if(interest <= 0) {
throw new IllegalArgumentException("Interest
should be greater than 0: " + interest);
}
if(period <= 0) {
throw new IllegalArgumentException("Period should
be greater than 0: " + period);
}
return amount*(1 + period*interest/100);
}
%>
Loan Calculator
simple.jsp
<html>
<head>
<title>Simple</title>
</head>
<body style="font-family:verdana;font-size:10pt;">
<%@ include file="header.html" %>
<%
double amount =
Double.parseDouble(request.getParameter("amo
unt"));
double interest =
Double.parseDouble(request.getParameter("inter
est"));
int period =
Integer.parseInt(request.getParameter("period"));
%>
<b>Pincipal using simple interest:</b>
<%= calculate(amount, interest, period) %>
<br/><br/>
<jsp:include page="footer.jsp"/>
</body>
</html>
29. <%@ page errorPage="error.jsp" %>
<%!
public double calculate(double amount, double
interest, int period) {
if(amount <= 0) {
throw new IllegalArgumentException("Amount
should be greater than 0: " + amount);
}
if(interest <= 0) {
throw new IllegalArgumentException("Interest
should be greater than 0: " + interest);
}
if(period <= 0) {
throw new IllegalArgumentException("Period should
be greater than 0: " + period);
}
return amount*Math.pow(1 + interest/100, period);
}
%>
Loan Calculator
compound.jsp
<html>
<head>
<title>Compound</title>
</head>
<body style="font-family:verdana;font-size:10pt;">
<%@ include file="header.html" %>
<%
double amount =
Double.parseDouble(request.getParameter("amo
unt"));
double interest =
Double.parseDouble(request.getParameter("inte
rest"));
int period =
Integer.parseInt(request.getParameter("period"))
;
%>
<b>Pincipal using compound interest:</b>
<%= calculate(amount, interest, period) %>
<br/><br/>
<jsp:include page="footer.jsp"/>
</body>
</html>
30. Example
Inventory
ListServlet
List.jsp
EditServlet DeleteServlet
Edit.jsp CreateServlet
Runs the SQL query
for listing inventory
Takes the RowSet in the
context and renders it
Runs SQL query to get a
record from item
Runs SQL query to
update the data in the
item table after editing
New.html
UpdateServlet
Takes a RowSet and
renders a form for editing
Deletes a record
from the item table
Runs SQL query to
create new record
Renders form for new item
31. package edu.albany.mis.goel.servlets;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import javax.sql.RowSet;
import sun.jdbc.rowset.CachedRowSet;
public class ListServlet extends HttpServlet {
public void init(ServletConfig config) throws
ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException {
doGet(req, res);
}
Inventory
ListServlet
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException {
try {
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Define the data source for the driver
String sourceURL = "jdbc:odbc:inventoryDB";
RowSet rs = new CachedRowSet();
rs.setUrl(sourceURL);
rs.setCommand("select * from item");
rs.execute();
req.setAttribute("rs", rs);
getServletContext().getRequestDispatcher("/List.jsp").
forward(req, res);
} catch(Exception ex) {
throw new ServletException(ex);
}
}
}
32. package edu.albany.mis.goel.servlets;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.DriverManager;
import javax.sql.DataSource;
import javax.sql.RowSet;
import sun.jdbc.rowset.CachedRowSet;
public class EditServlet extends HttpServlet {
public void init(ServletConfig config) throws
ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException {
doGet(req, res);
}
Inventory
EditServlet
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException {
try {
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Define the data source for the driver
String sourceURL = "jdbc:odbc:inventoryDB";
RowSet rs = new CachedRowSet();
rs.setUrl(sourceURL);
rs.setCommand("select * from item where id = ?");
rs.setInt(1, Integer.parseInt(req.getParameter("id")));
rs.execute();
req.setAttribute("rs", rs);
getServletContext().getRequestDispatcher("/Edit.jsp
").forward(req, res);
} catch(Exception ex) {
throw new ServletException(ex);
}
}
}
33. package edu.albany.mis.goel.servlets;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class UpdateServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
doGet(req, res);
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
Connection con = null;
try {
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Define the data source for the driver
String sourceURL = "jdbc:odbc:inventoryDB";
Inventory
UpdateServlet
// Create a connection through the DriverManager class
con = DriverManager.getConnection(sourceURL);
System.out.println("Connected Connection");
PreparedStatement stmt= con.prepareStatement
("update item " + "set name = ?, " + "description = ?, " + "price = ?, "
+ "stock = ? " + "where id = ?");
stmt.setString(1, req.getParameter("name"));
stmt.setString(2, req.getParameter("description"));
stmt.setDouble(3, Double.parseDouble(req.getParameter("price")));
stmt.setInt(4, Integer.parseInt(req.getParameter("stock")));
stmt.setInt(5, Integer.parseInt(req.getParameter("id")));
stmt.executeUpdate();
stmt.close();
getServletContext().getRequestDispatcher("/List").
forward(req, res);
} catch(Exception ex) {
throw new ServletException(ex);
} finally {
try {
if(con != null) {
con.close();
}
} catch(Exception ex) {
throw new ServletException(ex);
}
}
}
}
34. package edu.albany.mis.goel.servlets;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class DeleteServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
doGet(req, res);
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
Connection con = null;
Inventory
DeleteServlet
try {
// Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Define the data source for the driver
String sourceURL = "jdbc:odbc:inventoryDB";
// Create a connection through the DriverManager class
con = DriverManager.getConnection(sourceURL);
System.out.println("Connected Connection");
// Create Statement
PreparedStatement stmt =
con.prepareStatement("delete from item where id = ?");
stmt.setInt(1, Integer.parseInt(req.getParameter("id")));
stmt.executeUpdate();
stmt.close();
getServletContext().getRequestDispatcher("/List").
forward(req, res);
} catch(Exception ex) {
throw new ServletException(ex);
} finally {
try {
if(con != null) con.close();
} catch(Exception ex) {
throw new ServletException(ex);
}
}
}
35. package edu.albany.mis.goel.servlets;
import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class CreateServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
doGet(req, res);
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException {
Connection con = null;
try { // Load the driver class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Inventory
CreateServlet
// Define the data source for the driver
String sourceURL = "jdbc:odbc:inventoryDB";
// Create a connection through the DriverManager class
con = DriverManager.getConnection(sourceURL);
System.out.println("Connected Connection");
PreparedStatement stmt = con.prepareStatement
("insert into item " + "(name,description,price,stock) " +
"values (?, ?, ?, ?)");
stmt.setString(1, req.getParameter("name"));
stmt.setString(2, req.getParameter("description"));
stmt.setDouble(3, Double.parseDouble(req.getParameter("price")));
stmt.setInt(4, Integer.parseInt(req.getParameter("stock")));
stmt.executeUpdate();
stmt.close();
getServletContext().getRequestDispatcher("/List").forward(req, res);
} catch(Exception ex) {
throw new ServletException(ex);
} finally {
try {
if(con != null) con.close();
} catch(Exception ex) {
throw new ServletException(ex);
}
}
}
}
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Prevention: locks at doors, window bars, walls round the property
Detection: stolen items are missing, burglar alarms, closed circuit TV
Reaction: call the police, replace stolen items, make an insurance claim …
Prevention: encrypt your orders, rely on the merchant to perform checks on the caller, don’t use the Internet (?) …
Detection: an unauthorized transaction appears on your credit card statement
Reaction: complain, ask for a new card number, etc.
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases
Potential Damages:
1. Change orders placed by the client (Instead of 500 widgets he can make the order 50,000 widgets)
2. Change meeting venues to send people on wild goose chases