JSP overview JSP (IAVASERVERPAGES) is a dynamic web page creation technology developed by Sun in the java language, which allows you to separate dynamic parts of the web page from static HTML. You can use common handy tools to write HTML statements as usual. Then, embed the dynamic part with special tags, which are often outlined in JSP
JSP (iava server pages) is a dynamic web page creation technology developed by Sun in the java language. it allows you to separate dynamic and static HTML in web PAGES. You can use common handy tools to write HTML statements as usual. Then, embed the dynamic part with special tags, which often start with "<%" and end with "%>. For example, there is a JSP page:
Jsp tutorial
<% Out. println ("hello world"); %>
It will output "hello world ".
Generally, you need to take the file ". jsp" as the extension and place it under any path where you can place a normal web page. Although the JSP file looks more like an HTML file than a Servlet file, in fact, it will be converted to a Servlet file, where the static HTML is only used to output the information returned by the Servlet service method. If the JSP pages has been converted to Servlet and the Servlet is compiled and loaded (at the first Request), when you Request this JSP page again, you will not be able to detect a transient delay. Pay attention to this phenomenon. some Web Servers allow you to define aliases for them, as if a URL points to an HTML, but in fact it points to a Servlet or JSP pages.
Construct a JSP page. in addition to embedded rule HTML, there are three main JSP elements: Scripting elements, Directives, and Actions. with Scripting elements, you can define the part that is finally converted to Servlet. Directives allows you to control the overall structure of this Servlet, while Actions allows you to specify reusable existing components. In addition, you can also control the running of the JSP Engine. To simplify Scripting elements, you can take advantage of some predefined variables, such as request.
This tutorial is based on the latest version 1.1 of JSP. Its syntax is summarized in the following table. its detailed usage will be explained in detail in subsequent courses.
JSP elements
Syntax
Explanation
JSP Expression
<% = Expression %>
Expression is used for calculation and output.
Expression The predefined variables that can be used include request, response, out, session, application, config, and pageContext (which can also be used in Sriptlets ).
JSP Scriptlet
<% Code %>
Insert the code for the service.
Code
JSP Declaration
The Servlet code is not a service method.
Code
JSP page Directive
<% @ Page att = "val" %>
The path to the Servlet engine.
. The following are valid attributes (the default value is bold ):
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