Professional Documents
Culture Documents
- An Introduction
Sowmya Malagikar
26th October 2006
Objectives
To be able to define JSP
enterprise architectures To demonstrate the ability to write, debug and deploy JSPs
Page 1
Agenda
What is JSP ?
Page 2
What is JSP ?
Definition : * Mixing Static HTML With Dynamically Generated Content using Java technology * JSP is a dynamic scripting capability for web pages that allows java as well as a few special tags to be embedded into a web file (HTML/XML, etc). The suffix traditionally ends with .jsp to indicate to the web server that the file is a JSP file.
Page 3
Page 4
JSP Advantages
Separation of static from dynamic content
of formats
Page 5
Should be separated for optimal project management. JSP does this by allowing special Java tags in HTML
Page 6
MindTree Consulting Pvt Ltd Proprietary & Confidential
A Simple Example
package example.servlets;
Page 8
The underlying semantic model is that of a servlet A typical JSP container will translate the JSP page to a Java servlet
By default, translation and compilation of a JSP page is likely to occur the first time the page is accessed
Page 10
MindTree Consulting Pvt Ltd Proprietary & Confidential
Page 11
Page 12
Page 13
identical results to the end user JSP is an additional module to the Servlet Engine
Page 15
JSP Elements
Scriptlets of the form <% code %> that are inserted into the servlet's service method, and Directives g of the form <%@ ...%> gives JSP engine information for the page Expressions of the form <%= expression %> that are evaluated and inserted into the output Declarations of the form <%! code %> that are inserted into the body of the servlet class, outside of any existing methods
Page 16
Page 17
page is requested)
Page 18
Page 19
Page 20
Page 21
insert a file into the servlet class at the time the JSP file is translated into a servlet
indicates a library of custom tags that the page can include
taglib directive
Page 22
Directives - examples
The page directive lets you define the
following attributes:
import="package.class
Page 23
More Directives
isThreadSafe=true|false Normal servlet processing or implementing SingleThreadModel session=true|false Allowing/disallowing sessions buffer=sizekb|none specifies the buffer size for the JspWriter out autoflush=true|false Flush buffer when full or throws an exception when buffer isfull
Page 24
info=message
message for the getServletInfo method errorPage=url Define a JSP page that handles uncaught exceptions isErrorPage=true|false language=java
Page 25
the time the JSP page is translated into a servlet The directive looks like this: <%@ include file="relative url" %>
Page 26
Actions
JSP actions use constructs in XML syntax to control the behavior of the servlet engine You can
dynamically
insert a file,
reuse
JavaBeans components,
the user to another page, or HTML for the Java plugin
forward
generate
Page 27
Available Actions
Available actions include:
jsp:include -
requested jsp:useBean - Find or instantiate a JavaBean jsp:setProperty - Set the property of a JavaBean jsp:getProperty - Insert the property of a JavaBean into the output jsp:forward - Forward the requester to a new page jsp:plugin - Generate browser-specific code that makes an OBJECT or EMBED tag for the Java plugin
Page 28
Page 29
JSP resources
http://java.sun.com/products/jsp/
http://www.jguru.com/faq/index.jsp
http://archives.java.sun.com/archives/jspinterest.html
Page 30
Imagination
Page 31
Action
Joy
MindTree Consulting Pvt Ltd Proprietary & Confidential