JSP Grammar Learning Notes

Source: Internet
Author: User

1. Modify the JSP page template:
Locate the Myeclips installation directory, search for "JSP.VTL", find the file modification code, and some code that you do not need to use.

2. Find the path to the servlet file generated by the project:
View the current project parent catalog search. Metadata. Me_tcat->work->catalina You can find the code after the servlet translation in the child directory.


3, JSP page Global exception page configuration, error page configuration page directive iserrorpage= "True", you can get exception information
Webroot/web-inf/web.xml Configuration
<error-page>
<!--Exception-type must be configured node--
<exception-type> Exception Types </exception-type>
<!--Error-code not required to configure the node, specify the error code jump page number such as 404,500-->
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>

4. include directive:
Practical method: <%@ include file= "/web-inf/head.jsp"%>, file corresponding path is case-sensitive.
Note: Include for static too contains, dynamic including use method is:
<% request.getrequestdispatcher ("/web-inf/head.jsp"). Include (request, response); %>
The results are as follows. NET Response.Write will disrupt the page numbering structure

5, JSP Common tags
5.1, forward jump page:
Such as:
<jsp:forward page= "/01.jsp" >
<jsp:param value= "" name= "user"/>
</jsp:forward>

5.2, include: equivalent to <%@ include file= "* * *"%>
Such as:
<jsp:include page= "/web-inf/head.jsp" ></jsp:include>

6. JSP Mapping Configuration:
In the/web-inf/web.xml file, do the following configuration:
<servlet>
<servlet-name>rhythmk</servlet-name>
<jsp-file>/01.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>rhythmk</servlet-name>
<url-pattern>/rhythmk.html</url-pattern>
</servlet-mapping>

Request: http://loaclhost:8080/test/rhythmk.html equivalent to http://loaclhost:8080/test/01.jsp

7. JSP Page Number
<% Java code block%>
<%! Definition Method%>
<%--Java code-level annotations--%>

8. Page directive (<%@ page%>):
Session: Open session is enabled by default.
Pageencoding: Specifies the page number encoding format.
Import: Importing Java packages, multiple packages can be comma delimited import= "Package 1, Package 2" can also
<% import= "Pack 1"%>
<% import= "Pack 2"%>
IsThreadSafe: Thread safe, default "true"

Servlet Jump JSP

@WebServlet ("/hello")PublicClass HelloServletExtendsHttpServlet {PrivateStaticFinalLong Serialversionuid = 1L;/***@seeHttpservlet#httpservlet ()*/PublicHelloServlet () {Super();//TODO auto-generated Constructor stub}/***@seeHttpservlet#doget (HttpServletRequest request, httpservletresponse response)*/Protectedvoid Doget (HttpServletRequest request, httpservletresponse response)throws Servletexception, IOException {request.setattribute ("name", Request.getparameter ("name")); Request.getrequestdispatcher ("hello.jsp"). Forward (request,response);}}   

JSP Grammar Learning Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.