Subhasis Nayak CMC
<ul><li>Directives are used to inform  special processing information  about the page to the  JSP container . For example:...
<ul><li>There are 3 – types of JSP directives. </li></ul><ul><ul><li>Page directives </li></ul></ul><ul><ul><li>Include di...
<ul><li>Page directives </li></ul>
<ul><li>Page directive is the most complicated JSP directive. </li></ul><ul><li>primarily because it supports such a wide ...
<ul><li>White space after the opening  <%@  and before the closing  %>  is optional. </li></ul><ul><li>It is recommended t...
 
<ul><li>Remember JSP provides multiple page directives on a single page. </li></ul><ul><li>Do not import individual attrib...
<%@ page info=&quot;This is an invalid page directive&quot; session=&quot;false“  buffer=&quot;16k&quot; autoFlush=&quot;f...
<ul><li>The info attribute allows the author to add a documentation string to the page. </li></ul><ul><li>That summarizes ...
<ul><li>The language attribute specifies the language to be used in all scripting elements on the page. </li></ul><ul><li>...
<ul><li>his attribute is used to indicate the MIME type of the response being generated by the JSP page. </li></ul><ul><li...
<ul><li>It provides an alternate means for specifying the character set used by the JSP page. </li></ul><ul><li>It is intr...
<ul><li>Extends attribute identifies the superclass to be used by the JSP container when it is translating the JSP to a Ja...
<ul><li>It extends attribute, use of the import attribute is quite common, because it extends the set of Java classes whic...
<ul><li>The session attribute is used to indicate whether or not a JSP page participates in session management. </li></ul>...
<ul><li>The buffer attribute controls the use of buffered output for a JSP page. </li></ul><ul><li>To turn off buffered ou...
<ul><li>The specified value can therefore be thought of as the minimum buffer size for the page. </li></ul><ul><li>JSP con...
<ul><li>This attribute is also used for  controlling buffered output .  </li></ul><ul><li>In particular, this attribute  c...
<ul><li>isThreadSafe attribute is used to indicate whether your JSP page, once it is compiled into a Servlet, is capable o...
<ul><li>This attribute is used to specify an alternate page to display if an (uncaught) error occurs while the JSP contain...
<ul><li>The isErrorPage attribute is used to mark a JSP page that serves as the error page for one or more other JSP pages...
<ul><li>Include directive </li></ul>
<ul><li>The second JSP directive enables page authors to include the contents of one file in another.  </li></ul><ul><li>T...
 
<ul><li>Tag library directive  </li></ul>
<ul><li>This directive is used to notify the JSP container that a page  relies  on one or more custom  tag libraries . </l...
<%@ taglib uri=&quot;tagLibraryURI&quot; prefix=&quot;tagPrefix&quot; %> <ul><ul><li>uri attribute indicates the location ...
Upcoming SlideShare
Loading in …5
×

Jsp 02(jsp directives)2003

912 views

Published on

jsp Directives, java server page directives.
Details about java server page directives

Published in: Education, Technology
2 Comments
1 Like
Statistics
Notes
  • why not get downloading this ppt?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • why is it not available for download??
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
912
On SlideShare
0
From Embeds
0
Number of Embeds
83
Actions
Shares
0
Downloads
0
Comments
2
Likes
1
Embeds 0
No embeds

No notes for slide

Jsp 02(jsp directives)2003

  1. 1. Subhasis Nayak CMC
  2. 2. <ul><li>Directives are used to inform special processing information about the page to the JSP container . For example:- </li></ul><ul><ul><ul><li>may be used to specify the scripting language for the page </li></ul></ul></ul><ul><ul><ul><li>to include the contents of another page. </li></ul></ul></ul><ul><ul><ul><li>indicate that the page uses a custom tag library. </li></ul></ul></ul><ul><li>Directives do not directly produce any output to the user/client. </li></ul><ul><li>They generate side effects that change the way the JSP container processing . </li></ul>
  3. 3. <ul><li>There are 3 – types of JSP directives. </li></ul><ul><ul><li>Page directives </li></ul></ul><ul><ul><li>Include directive </li></ul></ul><ul><ul><li>Tag library directives. </li></ul></ul>
  4. 4. <ul><li>Page directives </li></ul>
  5. 5. <ul><li>Page directive is the most complicated JSP directive. </li></ul><ul><li>primarily because it supports such a wide range of: </li></ul><ul><ul><li>attributes </li></ul></ul><ul><ul><li>associated functionality </li></ul></ul><%@ page attribute1=&quot;value1&quot; attribute2=&quot;value2&quot; attribute3=… %>
  6. 6. <ul><li>White space after the opening <%@ and before the closing %> is optional. </li></ul><ul><li>It is recommended to increase readability . </li></ul><ul><li>Like other JSP tags it has a XML based form. </li></ul><ul><li>there are twelve different attributes recognized for the page directive. </li></ul>< jsp:directive.page attribute1=&quot;value1&quot; attribute2=&quot;value2&quot; attribute3=… />
  7. 8. <ul><li>Remember JSP provides multiple page directives on a single page. </li></ul><ul><li>Do not import individual attribute more than one time, that’s not supported. </li></ul><ul><li>Unrecognized attributes are invalid. </li></ul><%@ page info=&quot;This is a valid set of page directives.&quot; %> <%@ page language=&quot;java&quot; import=&quot;java.net.*&quot; %> <%@ page import=&quot;java.util.List, java.util.ArrayList&quot; %> It is valid
  8. 9. <%@ page info=&quot;This is an invalid page directive&quot; session=&quot;false“ buffer=&quot;16k&quot; autoFlush=&quot;false&quot; session=&quot;false&quot; %> It is not valid It is not valid because the session attribute used twice
  9. 10. <ul><li>The info attribute allows the author to add a documentation string to the page. </li></ul><ul><li>That summarizes its functionality of the page. </li></ul><ul><li>There is no restriction on the length of the documentation. </li></ul><ul><li>The default value is empty. </li></ul><%@ page info=&quot;The AyurVeda homepage, Copyright 2010 by Subhasis Nayak.&quot; %>
  10. 11. <ul><li>The language attribute specifies the language to be used in all scripting elements on the page. </li></ul><ul><li>Java is the default language used to do scripting. </li></ul><%@ page language=&quot;java&quot; %>
  11. 12. <ul><li>his attribute is used to indicate the MIME type of the response being generated by the JSP page. </li></ul><ul><li>MIME stands for Multipurpose Internet Mail Extensions . </li></ul><ul><li>MIME is also used to indicate the type of information contained in an HTTP response. </li></ul><ul><li>The most common MIME types for JSP are: </li></ul><ul><ul><ul><li>&quot;text/html“ </li></ul></ul></ul><ul><ul><ul><li>&quot;text/plain“ </li></ul></ul></ul><ul><li>The contentType attribute can also be used to specify an alternate character set for the JSP page. </li></ul>
  12. 13. <ul><li>It provides an alternate means for specifying the character set used by the JSP page. </li></ul><ul><li>It is introduced in JSP 1.2 </li></ul><ul><li>Instead of supplying the character set as part of the contentType attribute’s value, it can be declared independently. </li></ul><ul><li>The default character set for JSP pages is ISO-8859-1(latin-1). </li></ul>
  13. 14. <ul><li>Extends attribute identifies the superclass to be used by the JSP container when it is translating the JSP to a Java Servlet. </li></ul><ul><li>There is no default value for this attribute. </li></ul><ul><li>If this attribute is not specified , the JSP container is free to make its own choice of JSP Servlet class to use as the super class for the page. </li></ul><ul><li>Remember your super class must implements: </li></ul><ul><li>If an alternate protocol is being used, then the specified super class must implement the javax.servlet.jsp.JspPage interface. </li></ul>javax.servlet.jsp.HttpJspPage very rarely used
  14. 15. <ul><li>It extends attribute, use of the import attribute is quite common, because it extends the set of Java classes which may be referenced in a JSP page without having to explicitly specify class package names. </li></ul><ul><li>All Java classes and interfaces are associated with a package name; to completely specify. </li></ul><ul><li>The package name must be pretended to the class name. </li></ul><%@ page import=&quot;java.util.List.*&quot; %> <%@ page import=&quot;java.util.List,java.util.ArrayList, java.text.*&quot; %>
  15. 16. <ul><li>The session attribute is used to indicate whether or not a JSP page participates in session management. </li></ul><ul><li>The value for this attribute is a simple Boolean indicator: </li></ul><ul><ul><li>true </li></ul></ul><ul><ul><li>false </li></ul></ul><%@ page session=&quot;false&quot; %>
  16. 17. <ul><li>The buffer attribute controls the use of buffered output for a JSP page. </li></ul><ul><li>To turn off buffered output, so that all JSP content is passed immediately to the HTTP response, this attribute should be set to none, as follows: </li></ul><ul><li>The default value for this attribute is &quot;8kb“. </li></ul><%@ page buffer=&quot;none&quot; %>
  17. 18. <ul><li>The specified value can therefore be thought of as the minimum buffer size for the page. </li></ul><ul><li>JSP container is allowed to use an output buffer larger than the requested size. </li></ul><ul><li>This allows the JSP container to optimize performance. </li></ul><%@ page buffer=&quot;12kb&quot; %>
  18. 19. <ul><li>This attribute is also used for controlling buffered output . </li></ul><ul><li>In particular, this attribute controls the behavior of the JSP container when the page’s output buffer becomes full . </li></ul><ul><li>If this attribute is set to true , the output buffer will automatically be flushed . </li></ul><ul><li>Once flushed then processing resumes . </li></ul><%@ page autoFlush=&quot;true&quot; %>
  19. 20. <ul><li>isThreadSafe attribute is used to indicate whether your JSP page, once it is compiled into a Servlet, is capable of responding to multiple simultaneous requests. </li></ul><ul><ul><li>set to false – if you have not more than one thread </li></ul></ul><ul><ul><li>Set to true - if you have multiple threads. </li></ul></ul><ul><li>Default one is true, if you have more only one thread be sure to change the default value to false. </li></ul>
  20. 21. <ul><li>This attribute is used to specify an alternate page to display if an (uncaught) error occurs while the JSP container is processing the page. </li></ul><ul><li>This alternate page is indicated by specifying a local URL as the value for this attribute, as in the following: </li></ul><%@ page errorPage=&quot;/misc/error.jsp&quot; %>
  21. 22. <ul><li>The isErrorPage attribute is used to mark a JSP page that serves as the error page for one or more other JSP pages. This is done by specifying a simple boolean attribute value, as follows: </li></ul><ul><li>When this attribute is set to true, it indicates that the current page is intended for use as a JSP error page. </li></ul><%@ page isErrorPage=“true”%>
  22. 23. <ul><li>Include directive </li></ul>
  23. 24. <ul><li>The second JSP directive enables page authors to include the contents of one file in another. </li></ul><ul><li>The file to be included is identified via Url. </li></ul><ul><li>The directive has the effect of replacing itself with the contents of the indicated file. </li></ul><ul><li>There are no restrictions on the number of include directives in a single page. </li></ul><ul><li>There are also no restrictions on nesting. </li></ul><ul><li>The syntax of the include directive is as follows: </li></ul><jsp:directive.include file=&quot;localURL&quot; />
  24. 26. <ul><li>Tag library directive </li></ul>
  25. 27. <ul><li>This directive is used to notify the JSP container that a page relies on one or more custom tag libraries . </li></ul><ul><li>A tag library is a collection of custom tags that can be used to extend the functionality of JSP on a page basis. </li></ul><ul><li>Once this directive has been used to indicate the reliance of a page on a specific tag library, all of the custom tags defined in that library become available for use on that page. </li></ul>
  26. 28. <%@ taglib uri=&quot;tagLibraryURI&quot; prefix=&quot;tagPrefix&quot; %> <ul><ul><li>uri attribute indicates the location of the Tag Library Descriptor (TLD) file for the library. </li></ul></ul><ul><li>prefix attribute specifies the XML namespace identifier that will be prepended to all occurrences of the library’s tags on the page. </li></ul><%@ taglib uri=&quot;/EncomTags&quot; prefix=&quot;mcp&quot; %>

×