JSP coding specifications

Source: Internet
Author: User

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

 

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.