Java Code Summary _jsp programming in JSP

Source: Internet
Author: User

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

Related Article

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.