Professional Documents
Culture Documents
Web server/servlet engine Check to see if the file has changed since last compiled
Existing servlet
Compile to a servlet
DIRECTIVES
Directives are elements that provide global information, about an entire JSP page. Three types of directives Page Directive Include Directive
Taglib Directive
isThreadSafe=boolean
Specifies that the jsp engine can service more than one thread is set to true.
Refers to the file name which will handle the exceptions. This attribute states whether or not a jsp page is an error page. Default is false.
6
errorPage=filename isErrorPage=boolean
Multiple err pages can be defined based on err code and exception type
Err.jsp
Home.jsp
.. ..
Single Servlet
Complied
Index.jsp
req thread
instance
.class
10
res
Index.jsp
11
ACTION TAGS
Actions are used for encapsulating common tasks. Especially used to create objects of java beans. <jsp:include> <jsp:forward> Includes static and dynamic page. Dispatches the current page to another resource (html, servlet, jsp). Used to pass values using a name and value pair.
<jsp:param>
12
ACTION TAGS
<jsp:useBean> <jsp:setProperty> <jsp:getProperty> Associates an instance of a Bean. Sets the Value for the Bean Property Retrives the Value from the Bean Property
13
<jsp:include> Action
<jsp:include page= First.jsp > <jsp:param name=name value=ram/> <jsp:include>
Home.jsp
Jsp param tag encrypts special characters such as blank space, &, >,< etc
First.jsp The parameters are passed to the included file at run time and then it includes
14
<jsp:forward> Action
<jsp:forward page= second.jsp > <jsp:param name=name value = ram/ > </jsp:forward>
This happens at run time The equivalent code in servlet RequestDispatcher rd = request.getRequestDispatcher(Second.jsp); rd.forward(request,response); Note: parameters can take only string values
15
Equivalent code in java (Form submit) <%Person per = new Person(); %>
property
value
Identifies the bean instance Identifies the setter method in the bean class If html control parameters are same as bean fields, No need of param attr
17
setProperty
<input type="text" name="empName"/>
setEmpName(String empName)
18
19
Posted to
20
21
Jsp:useBean demo
Posted to
22