Lets look at some old JSP terminologies
JSP's are servlets
All Jsps get translated to servlets during runtime. The servlet class name is normally decided by the servlet container . All these servlet classes extends implements jspPage interface . When requested for the first time ,webserver compiles JSP page to the class and on subsequent requests it doesn't re compiles unless changes has been observed in the JSP Page .
JSPInit() and JSPDestroy()
You can override JSPInit and JSPDestroy() methods in the JSP declaration tags. Doing this allows you the handle to the init() and destroy() functions of the jsp servlet.
JSP mappings in web.xml
JSP's are mapped in web.xml's to a particular url pattern . Init Parameter is also defined here.
Implicit Objects
There are set of implicit objects in JSP pages which you can use without declaring it explicitly .
They are :
request - servletRequest
response - servletResponse
out - PrintWriter (JspWriter)
session - HTTPSession
application - ServletContext
config - ServletConfig
pageContext - pageContext
page - JspPage
exception - Throwable
Scopes of Variables in JSP
In Jsp a variable can be stored in 4 Scopes page, request , session and applicationScope
page - only for the page, request - ServletRequest , session - HttpSession , application - ServletContext . The setAttribute method in PageContext has the following signature:
public abstract void setAttribute(java.lang.String name,
java.lang.Object value, int scope)
The value of scope can be one of the following static final ints in PageContext: PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE.
JSP Include Directive
<%@include file ="url" /> is known as include directive in JSP pages. These are used to keep the code separated and have a modular architecture . When we do a jsp page include, it replaces the directive with the contents of the url page.
Scriptlets , Expressions and Directives
The scriplets are "<%" which shows beginning of the java code in JSP page .
"<%=" are Expressions which calls a method and returns the value to output stream of JSP
"<%! " are directives which mark starting of a method definitions in the JSP page
JSP's are servlets
All Jsps get translated to servlets during runtime. The servlet class name is normally decided by the servlet container . All these servlet classes extends implements jspPage interface . When requested for the first time ,webserver compiles JSP page to the class and on subsequent requests it doesn't re compiles unless changes has been observed in the JSP Page .
JSPInit() and JSPDestroy()
You can override JSPInit and JSPDestroy() methods in the JSP declaration tags. Doing this allows you the handle to the init() and destroy() functions of the jsp servlet.
JSP mappings in web.xml
JSP's are mapped in web.xml's to a particular url pattern . Init Parameter is also defined here.
Implicit Objects
There are set of implicit objects in JSP pages which you can use without declaring it explicitly .
They are :
request - servletRequest
response - servletResponse
out - PrintWriter (JspWriter)
session - HTTPSession
application - ServletContext
config - ServletConfig
pageContext - pageContext
page - JspPage
exception - Throwable
Scopes of Variables in JSP
In Jsp a variable can be stored in 4 Scopes page, request , session and applicationScope
page - only for the page, request - ServletRequest , session - HttpSession , application - ServletContext . The setAttribute method in PageContext has the following signature:
public abstract void setAttribute(java.lang.String name,
java.lang.Object value, int scope)
The value of scope can be one of the following static final ints in PageContext: PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, and APPLICATION_SCOPE.
JSP Include Directive
<%@include file ="url" /> is known as include directive in JSP pages. These are used to keep the code separated and have a modular architecture . When we do a jsp page include, it replaces the directive with the contents of the url page.
Scriptlets , Expressions and Directives
The scriplets are "<%" which shows beginning of the java code in JSP page .
"<%=" are Expressions which calls a method and returns the value to output stream of JSP
"<%! " are directives which mark starting of a method definitions in the JSP page
No comments:
Post a Comment