JSP coding specifications
JSP files can contain the following content:
HTML (CSS, JavaScript) Comments (previously mentioned in a blog post) Java code directive implicit objects
I. HTML code on the JSP page
-The HTML in the JSP page includes:
-HTML Tag-CSS-JavaScript
Purpose: control the effect of making a page in a browser.
Rules for converting to Servlet
The out. write statement of the service () method in the Servlet.
Ii. Java code on the JSP page
The Java code on the JSP page contains the following three types:
JSP expression JSP small script JSP Declaration
Location: any location of the page
Purpose: control the generation of variable content on the page
1. JSP expressions
Syntax Rules: <% = ...... %> Valid content: Variable, expression of variable plus operator combination, method with return value
Rules for converting to Servlet: Use the out. print statement in the service () method to output the values of this variable, expression, and method.
For example:
Response + response + a1xNK7ts60 + sLrPGJyIC8 + DQrA/cjno7o8YnIgLz4NCjxpbWcgYWx0PQ = "JSP script" src = "http://www.bkjia.com/uploads/allimg/150830/062HL944-1.png" title = "\"/>
3. JSP Declaration
Syntax Rules: <%! ...... %> Valid content: Member attribute or member method declaration
Rules for converting to Servlet: The member attributes or member methods in the Servlet class to be translated from the JSP page
For example:
3. commands on the JSP page
Syntax rule: <% @ command name attribute = Value %> Common commands:
Page command include command taglib command: controls the content generated when JSP is converted into Servlet classes
1. page command
Role: used to export packages and set page properties
For example:
2. include command
Purpose: Include other files when converting a JSP page to a Servlet. It can contain JSP files or static HTML files.
This statement can easily include the navigation bar, copyright notice, logo and other syntaxes on each JSP page: <% @ include file = "url" %>
For example:
<% @ Include file = "date. jsp" %>
See the following figure:
How to convert JSP into Java