There are two minor exceptions to sending to the client intact:
1. If you want to transfer <% or%>, because it is consistent with the special symbols of the JSP, you must use the Escape word escape, <\% or%\>
2. If you want to send a comment that appears in the JSP editing page, and the resulting HTML document does not appear, then we use <%----%>, and the <!----> This form is passed to the client intact.
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
JSP expressions are used to insert values directly into the output, <%= Java expressions%>
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: <%= new Java.util.Date ()%>
Predefined variables, request, reponse, session, out, application