Top Banner
JSP ELEMENTS BY SANA MATEEN
19

Jsp elements

Mar 19, 2017

Download

Education

Nuha Noor
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Jsp elements

JSP ELEMENTS

BYSANA MATEEN

Page 2: Jsp elements

3 Kinds of Elements

Scripting DirectiveAction

1. <%......%>2. <%=……%>3. <%!......%>

1. <%@page.......%>2. <%@include....%>

3. <%taglib….%>

1. <jsp:useBean>2. <jsp:getProperty>3. <jsp:setProperty>

4. <jsp:include>5. <jsp:forward>

Page 3: Jsp elements

Jsp directive elements• The jsp directives are messages that tells the web container how to translate a

JSP page into the corresponding servlet.• There are three types of directives:

1. page directive2. include directive3. taglib directive

• The page directive defines attributes that apply to an entire JSP page.• Attributes of JSP page directive

1. import2. contentType3. extends4. info5. buffer6. language7. isELIgnored8. isThreadSafe9. autoFlush10. session11. pageEncoding12. errorPage13. isErrorPage

Page 4: Jsp elements

The page Directive:Following is the list of attributes associated with page directive:

Attribute Purpose buffer Specifies a buffering model for the output stream.autoFlush Controls the behavior of the servlet output buffer.contentType Defines the character encoding scheme.errorPage Defines the URL of another JSP that reports on Java unchecked

runtime exceptions.isErrorPage Indicates if this JSP page is a URL specified by another JSP page's

errorPage attribute.extends Specifies a superclass that the generated servlet must extendimport Specifies a list of packages or classes for use in the JSP as the Java

import statement does for Java classes.info Defines a string that can be accessed with the servlet's

getServletInfo() method.isThreadSafe Defines the threading model for the generated servlet.language Defines the programming language used in the JSP page.session Specifies whether or not the JSP page participates in HTTP sessionsisELIgnored Specifies whether or not EL expression within the JSP page will be

ignored.isScriptingEnabled Determines if scripting elements are allowed for use.

Page 5: Jsp elements
Page 6: Jsp elements
Page 7: Jsp elements
Page 8: Jsp elements
Page 9: Jsp elements
Page 10: Jsp elements
Page 11: Jsp elements
Page 12: Jsp elements

Jsp Include Directive• The include directive is used to include the contents of any resource it may

be jsp file, html file or text file. The include directive includes the original content of the included resource at page translation time

• Advantage of Include directive• Code Reusability• Syntax of include directive• <%@ include file="resourceName" %>

Page 13: Jsp elements

JSP Taglib directive• The JSP taglib directive is used to define a tag library that defines many

tags. We use the TLD (Tag Library Descriptor) file to define the tags. In the custom tag section we will use this tag so it will be better to learn it in custom tag.

• Syntax JSP Taglib directive• <%@ taglib uri="uriofthetaglibrary" prefix="prefixoftaglibrary" %>

Page 14: Jsp elements

Jsp Action Elements

• JSP Action Tags• There are many JSP action tags or elements. Each JSP action tag is used

to perform some specific tasks.• The action tags are used to control the flow between pages

If plugin is not working

Page 15: Jsp elements
Page 16: Jsp elements
Page 17: Jsp elements
Page 18: Jsp elements

Jsp param• The <jsp:param> action is used to provide information in the form of

key/value pair. • This action can be used as direct child element of the following

actions: <jsp:include>, <jsp:forward> and <jsp:params> (which is a child element of the <jsp:plugin> action).

• The JSP compiler will issue a translation error if this element is used elsewhere.

• Syntax• The <jsp:param> action has pretty simple and straightforward syntax:• <jsp:param name="paramName" value="paramValue" />• Both of the attributes paramName and paramValue are mandatory, and

the paramValue can accept a runtime expression.• For the <jsp:include> and <jsp:forward> actions, the parameters will be

added to the request object of the included page and forwarded page

Page 19: Jsp elements