JSP three major instructions
a JSP page, you can have a definition of 0~n instructions!
1. Page-and Most complex:<% @page language= "java" info= "xxx" ...%>
* pageencoding and contenttype:
>pageencoding:It specifies the current JSP page encoding, as long as not to lie, there will be no garbled! You need to use pageencoding! when the server wants to compile the JSP into. Java
>ContentType:it represents the addition of a response header: content-type! equivalence with Response.setcontenttype ("text/html;charset=utf-8");
> If two properties only provide one, then the other default is set that One.
> If two properties are not set, the default is ISO
* Import: Guide package! Can appear multiple times
* ErrorPage and Iserrorpage
>ErrorPage:if the current page throws an exception, which page to forward to , specified by ErrorPage
>Iserrorpage:It specifies whether the current page is an error-handling page! when This property is true, the page will be set to a status code of 500! And this page can use the exception! in 9 Large built-in objects Exception
Configuration exception in Web. XML
<Error-page> <Error-code>404</Error-code> < location>/error/errorpage.jsp</ location> </Error-page> <Error-page> <Error-code>500</Error-code> < location>/error/errorpage.jsp</ location> </Error-page> <Error-page> <Exception-type>Java.lang.RuntimeException</Exception-type> < location>/index.jsp</ location> </Error-page>
* autoflush and buffer
>AutoFlush:Specifies whether the JSP output stream buffers are automatically refreshed when the buffer is full! The default is true, and if false, throws an exception when the buffer is full!
>Buffer:Specifies the buffer size, which defaults to 8KB and does not usually need to be modified!
* Iselignored: whether to ignore the EL expression, The default value is false, not ignored, that is, support!
*page Other instructions (basic Useless)
>language: Specifies the language type of the current JSP compilation and the default value is Java.
>InfoInformation
>IsThreadSafe: Does the current JSP support concurrent access?
>Session: Whether the current page supports session, if false, then the current page has no session of this built-in object!
>extends: Let the jsp-generated servlet inherit the class specified by this property!
2. include--static inclusions
* Similar to the features of Requestdispatcher's include () method!
* <% @include%> It is done when the JSP is compiled into a Java file! Together they generate a Java (that is, a servlet) file and then generate a class!
* Requestdispatcher's include () is a method that contains and is comprised of two servlets, or Two. class! They just merge the content of the response at run time!
* role: decomposition of the page, the use of a combination of methods, such a page is a constant part of a separate jsp, and we only need to deal with the change of the Page.
3. Taglib---import Tag Library
* Two properties:
>prefix:specify the prefix of the tag library in this page! by our own name!
>URI:Specify the location of the tag library!
> <% @taglib prefix= "s" uri= "/struts-tags"%> prefix usage <s:text>
====================================================================================================
Nine built-in objects
* out--the JSP output stream, which responds to the client
* page --current JSP object! Its reference type is object, which is the following code in the Flesh:Object page = this;
* config -it corresponds to the ServletConfig object in the flesh!
*PageContext--a Top of 9!
*Request-httpservleteequest
* Response -HttpServletResponse
* Exception -Throwable Exception
*Session-HttpSession
* Application -ServletContext
1. PageContext
* One top 9!
* There are three domains in the servlet, and there are four fields in the jsp, which is the last domain object!
>servletcontext: the entire application
>session : Entire conversation (only one user in a Session)
>request: a chain of requests!
>Pagecontext: a JSP page! This field is used to share data between the current JSP page and the tags currently in use in the current JSP page!
>domain Object
>Proxy Other domains:pagecontext.setattribute ("xxx", "xxx", pagecontext.session_scope);
>Global Lookup:Pagecontext.findattribute ("xxx");// from small to large, rely on find! page, erqust, session, application
>gets the other 8 built-in Objects.
===================================================================================================
Special configuration of XML
<reloadable= "true">
The role in COntext.xml is to automatically load Tomcat
JSP Action Tags
the action tags of these jsps are essentially different from the tags provided by html.
* action tag is performed by Tomcat (server) to interpret! It is executed on the server side, just like Java code!
* HTML is executed by the browser!
*<jsp:forward>:forward! It is the same as the forward method of requestdispatcher, one is used in servlet, one is used in jsp!
*<jsp:include>:include: It is the same as the requestdispatcher include method, one is used in the servlet, one is used in the jsp!
><% @include >What's the difference between <jsp:include>!
*<jsp:param>:It is used as a sub-label for forward and include! Used to pass parameters to forwarded or included pages! //with Requstde's getparameter
Javaweb and JSP directives