Controlling the Structure of Generated Servlets: The JSP page Directive
. JSP Page Directives
The page directive is used to define attributes that apply to an entire JSP page.
There attributes of page directive are, language, extends, import, session, buffer, autoFlush, isThreadSafe, info, errorPage,
contentType, isErrorPage, pageEncoding, isELIgnored
JSP Page Directives : language
Used for specifying other scripting languages to be used in a JSP page.
JSP Page Directives : extends
Used for specifying some other java classes to be used in a JSP page.
The name is fetched from the java file. and display in jsp file.
JSP Page Directives : import
Used for importing packages or java classes.
JSP Page Directives : session
Used for controlling session management.
By default session object is available as u an see the code complied without error
when we set the session value to false the session is not more available to jsp page.
JSP Page Directives : buffer
Used by the out object to handle output generated by the JSP page.
JSP Page Directives : autoFlush
Used for controlling buffer flow.
JSP Page Directives : isThreadsafe
Used to control the request handling feature.
JSP Page Directives : info
Used to set some description for the page..
JSP Page Directives : errorPage
Used to set the error page to be called if any error occurs.
when the error error1.jsp run it throw an exception.
when the exception is thrown it transfer the control to error.jsp which is an error page defined in the page attribute of the error1.jsp page.
JSP Page Directives : contentType
Used to specify the MIME type.
JSP Page Directives : isErrorPage
Used to specify if the jsp page is an error page or not
JSP Page Directives : pageEncoding
Used to specify the language that the page uses when the page is sent to the browser.
JSP Page Directives : isELIgnored
Used to control the EL expression evaluation in the JSP page
JSP Static and Dynamic Inclusions
It can be done using the "include" directive.
<% @include file="included.html" %>
This is done at compile time not at run time.
It can be done using the <jsp: include> action tag
<jsp:include page="included.html" />
This is done at compile time not at compile time.
JSP Implicit Variables and Objects
JSP Page Scopes
This scope helps to keep the data available while the page is loading. Any object whose scope is defined as page scope will disappear as soon as the response is sent to the browser. The object with a page scope may be modified as often as desired within the particular page but the changes are lost as soon as the user moves away from the page. By default all beans have page scope.
JSP Page Scopes: Request
Any object created in the request scope will be available as long as the request object is valid. For example if the JSP page uses a <jsp:forward> tag, then the bean will be accessed in the forwarded page and if redirect is used then the bean is destroyed.
JSP Page Scopes: Session
In JSP terms, the data associated with the user has session scope. A session does not correspond directly to the user; rather, it corresponds with a particular period of time the user spends at a site. Typically, this period is defined as all the hits a user makes to a website between starting and exiting his browser.
JSP Page Scopes: Application
The bean associated with the application scope will be accessible to all the users and all the pages in the application.