1. Modify the character set jsp
Because jsp default character set is not utf-8, it will appear garbled Chinese, it is necessary to modify jsp character set is utf-8 WindowàPreferencesàWebàJSP Files
2. how to write Java code in JSP
In the JSP script fragment edit Java code, the format is: (<%>)
3.jsp operating environment
jsp page can not be opened directly through the website, you need to run Tomcat server opens
4. jsp expression
JSP is used to effect expression output object to the browser format is: (<% =%>)
request.getParameter () method is to obtain parameters from HTML form pages
5. jsp comments
JSP comments in the format: <% - -%>, but verified - may also be used <! ->
6. jsp nine implicit objects
① out (JspWriter): corresponds response.getWriter () Gets an object for displaying information on the page.
② config (ServletConfig): ServletConfig object corresponding to the Servlet.
③ page (Object): Servlet corresponding to the current object is actually this.
④ pageContext (PageContext): the context of the current page, is also a domain object.
⑤ exception (Throwable): Error page exception object
⑥ request(HttpServletRequest):HttpServletRequest对象
⑦ response(HttpServletResponse):HttpServletResponse对象
⑧ application(ServletContext):ServletContext对象
⑨ session(HttpSession):HttpSession对象
JSP is the hidden objects in script fragment can be called directly
7. jsp 4 domain
Four domains: the role is to transfer data (what data terminal interaction before and after?)
Domain page:
Range: the current page
Corresponding domain objects: pageContext
Type domain object: pageContext
request domain:
Range: the current request (first request)
Corresponding domain objects: request
Type domain objects: HttpServletRequest
session域:
Scope: The current session (first session)
Corresponding domain objects: session
Type domain object: HttpSession
application域:
Range: the current Web application
Corresponding domain objects: application
Type domain object: ServletContext
Four domain has the following three methods:
void setAttribute(String key,Object value)
Object getAttribute(String key)
void removeAttribute(String key)
Four domain objects using rules:
Do not use small large
8. forwarded role
Since the request is a one-time, go to another page parameters need to forward
9. Log in page fault handling
requestScope: as an attribute EL expression, it can pinpoint reqeust domain not found return null, otherwise it is in the order of four domain lookup, or null if not found,
msg: msg is a key request domain, written in the servlet page, called HTML page, the return value is the value servlet page request
Request: Request is one of the four domains, getAttribute and setAttribute by transmitting data, format key-value pair is not found return null
10. Span tag
<Span> for rows within the document elements are combined.
<Span> tag is no fixed format performance. When the style applied to it, it will produce visual changes.
<Span> tag provides a way independent of the text portion of the document or part.
11. Seesion used in the java file request.getSeesion () (transmission verification seesion)
12. The removal of a null value
JSP expressions directly using <% = request.getAttribute ( "Key")%> in JSP pages, obtained when the wrong result is displayed null, the processing required
Using an EL expression even get the wrong parameters will appear empty, do not need treatment, the use of EL parameters can accurately find the required domain
13. THE
One of the functions is used instead of expression in JSP
EL full name: Expression Language expression language
Action: is mainly used to output the value of the attribute of the object field
EL expressions query rules:
Find domain start page, return directly after the find, no longer look to other domains, if no request to go look for the domain, and so on, if you still can not find the application domain null is returned
EL provides us with a four scope object, to obtain the exact value of the specified attribute domain
pageScope
Gets the property value domain page
requestScope
Gets the property value request domain
sessionScope
Gets the property value domain session
applicationScope
Gets the property value application domain
EL expressions are: $ {}
EL precise sequential use lookup lookup field can replace JSP
Search order is:.. EL expression Key attributes of the value of domains
14. PageContext of other uses
PageContext domain can allow certain objects or features in the JSP provided in EL
15. jsp operating principle:
The first transmission request when:
When the first step in accessing jsp, jsp page translated into java file
The second step JVM java files compiled into class files
The third step servlet written to object to call the front page
Later, when retransmission request, the page without changing the premise of a direct call to the front page of the object