Assumerver Pages (JSP) enables us to separate static HTML and dynamic parts of the page. HTML can be written using any commonly used Web production tool in the same way as the original one. Dynamic code is placed in special marks, most of which start with "<%, end with "%>. For example, the following is a piece of JSP page. If we use http: // host/OrderConfirmation. jsp? Title = Core + Web + Programming this URL opens this page, the result shows "Thanks for ordering Core Web Programming ".
Thanks for ordering
<I> <% = request. getParameter ("title") %> </I>
JSP page files generally use. jsp as the extension and can be installed in any place that can store common web pages. Although from the code writing perspective, JSP pages are more like common Web pages than servlets, in fact, JSP will eventually be converted into a formal Servlet, static HTML is directly output to the output stream associated with the Servlet service method.
The conversion process from JSP to Servlet is generally performed when the first page request appears. Therefore, if you want the first user not to wait too long because the JSP page is converted into a Servlet, make sure that the Servlet has been correctly compiled and loaded, you can request this page after installing the JSP page.
Note that many Web servers allow alias definitions, so a URL that looks to point to an HTML file may actually point to a Servlet or JSP page.
In addition to common HTML code, there are three main elements embedded into the JSP page: Scripting Element, Directive, and Action ). The script element is used to embed Java code, which will become part of the converted Servlet. JSP commands are used to control the Servlet structure as a whole; action is used to introduce existing components or control the behavior of the JSP Engine. To simplify the script elements, JSP defines a set of variables that can be directly used (pre-defined variables). For example, the request in the previous code snippet is one of them.
Note that this article is based on the JSP 1.0 specification. Compared with version 0.92, the new version of JSP has made many major changes. Although these changes only make JSP better, it should be noted that 1.0 of JSP pages are almost completely incompatible with the early JSP Engine.
11.2 JSP syntax summary table JSP element syntax description remarks
JSP expression <% = expression %> calculates the expression and outputs the result.
The equivalent XML expression is:
<Jsp: expression>
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.