Most of the time, most of the JSP documents consist of static text (HTML), and the servlet created to process the page simply passes them to the client
There are two minor exceptions to sending to the client intact:
1. If you want to transfer, because it is consistent with the special symbols of the JSP, you must use the escape character escape, <% or%>
2. If you want to send comments, appear in the JSP edit page, and the resulting HTML document does not appear, then we will use, and this form will be passed intact to the client.
JSP calls dynamic code policy
Using MVC, a servlet handles the initial request, looks up the data, stores the results in the bean, and then forwards the request to the JSP page to submit the final result, and the JSP page uses the bean.
Java Code Location
Now JSP page Java code, it is best to put some Java code in the class, and then put the Java class in Web-inf/classes/directory/machingpackagename, and then use 1 or 2 lines based on JSP code to call it. The reasons are as follows:
1. Development, we generally write general Class (Java) in the object-oriented development environment, in the HTML-oriented environment, such as Dreadweaver, write JSP.
2. Compile, to compile the normal Java class, order in the IDE compiled, to compile the JSP page, you must put it in the correct directory, start the server.
3. Debugging, IDE debugging of individual environment is more convenient
4. Work division, proficient in Java personnel only focus on Java, proficient in HTML people focus on HTML.
5. Test, can be independently tested
6. Reuse. You can take advantage of the same Java class on multiple JSP pages.
The package is very important, and all the classes are put in care.
Use of JSP expressions
A JSP expression is used to insert a value directly into the output.
The expression is evaluated, converted to a string, and inserted into the page, evaluated at run time (when the page is requested), so that all the requested information can be accessed.
For example: Current time:
Predefined variables, request, reponse, session, out, application