Presentation is loading. Please wait.

Presentation is loading. Please wait.

JSP implicit objects & directive elements

Similar presentations


Presentation on theme: "JSP implicit objects & directive elements"— Presentation transcript:

1 JSP implicit objects & directive elements
Lec - 35

2 JSP Journey directive elements ………………………. scripting elements
JSP comments………………………………. declarations ………………………………… expressions …………………………..…….. scriptlets……………………………… action elements special JSP tags ………………………….…. implicit objects

3 Implicit Objects

4 Implicit Objects Objects that can be used in scriplets & expressions without defining them before. request response out Session application config pageContext exception page

5 Implicit Objects cont. request: javax.servlet.HttpServletRequest
request object that is the reason for the servlet to run response: javax.servlet.HttpServletResponse Response for the request out: javax.servlet.jsp.JspWriter Output stream writer

6 Example of Implicit Objects
web.jsp If page = = web index.jsp controller .jsp If page = = java java.jsp

7 Use of implicit objects
Example Code Use of implicit objects

8 JSP Journey directive elements ………………………. scripting elements
JSP comments………………………………. declarations ………………………………… expressions …………………………..…….. scriptlets……………………………… action elements special JSP tags ………………………….…. implicit objects

9 JSP Directives

10 JSP Directives Used to convey special processing information about the page to JSP container Enable programmer to: Specify page settings Include content from other resources Specify custom-tag libraries

11 JSP Directives cont. Format JSP directives
directive {attribute=“val”}* %> JSP directives page: page {attribute=“val”}* %> include: include {attribute=“val”}* %> taglib: taglib {attribute=“val”}* %>

12 JSP page Directive

13 JSP page Directive Give high level information about servlet that will result from JSP page Can be used anywhere in the document Can control Which classes are imported What class the servlet extends What MIME type is generated How multithreading is handled If the servlet participates in session Which page handles unexpected errors

14 JSP page Directive cont.
Defines attributes of the page page {attribute=“val”}* %> Some Attributes language = “java” extends = “package.class” import = “package.*,package.class,…” session = “true | false” Info = “text” contentType = “mimeType” isThreadSafe = “true | false” errorPage = “relativeURL” isErrorPage = “true | false” Language specifies what language Directives provide global information that is conceptually valid independent of any specific request received by the JSP page. Compile time information.

15 JSP page Directive cont.
Some example uses are: To import the package like java.util page import = “java.util.*” info = “using util package” %> To declare this page as an error page page isErrorPage = “true” %> To generate the excel spread sheet page contentType = “application/vnd.ms-excel” %> Language specifies what language Directives provide global information that is conceptually valid independent of any specific request received by the JSP page. Compile time information.

16 JSP include Directive

17 JSP include Directive Lets you include (reuse) navigation bars, tables and other elements in JSP page You can include files at Translation Time (by using include directives) Request Time (by using Action elements)

18 Including Pages at Translation Time using include directive
Format file=“relativeURL”%> Purpose To include a file in JSP document at the time document is translated into a servlet. May contain JSP code that affect the main page such as response header settings etc.

19 use of include directive
Example Code use of include directive

20 Generate Excel Spread-sheets by setting content type
Modify Last Example to Generate Excel Spread-sheets by setting content type

21 XML Syntax for Directives
<jsp:directive.directiveType attribute=“value” /> For example, the XML equivalent of page import = “java.util.*” %> Is <jsp:directive.page import=“java.util.*” />

22 JSP Journey directive elements ………………………. scripting elements
JSP comments………………………………. declarations ………………………………… expressions …………………………..…….. scriptlets……………………………… action elements special JSP tags ………………………….…. implicit objects

23 JSP Life Cycle Methods

24 JSP Life Cycle Methods jspInit() _jspService() jspDestroy() Request
Response _jspService() jspDestroy()


Download ppt "JSP implicit objects & directive elements"

Similar presentations


Ads by Google