01_01 JSP Basic syntax

Source: Internet
Author: User

JSP Basic Syntax

First, comments

1. Explicit annotations, client-visible

<!-- Comment -

2. implicit annotation, client not visible

// Comment Line

/* Comment Multiple lines * /

<%--jsp Comment -

Second, Scriptlet

1. the first type of scriptlet: <%%>

Can be used to define local variables , write statements, etc.

<% int x = 10;    String info = "www.126.com";    Out.println ("

2. the second type of scriptlet: <%!%>

You can define global variables, methods, classes

<%!    public static finalString INFO =  "Www.126.com";     int x = 10;%><%!    public int add (int  x,int y) {        return x+y;    }% ><%!    class person{        private  Stringname;        private int age;         publicperson (string name, int age) {         this.name = name;        this.age =  age;        }         Public stringtostring () {        return "name="  +  this.name + ";  age=" &Nbsp;+ this.age;        }    }%><%     out.println ("

3. the third type of scriptlet: <%=%>, also known as an expression output

The main function is to output a variable or a specific constant

<% String info = "www.126.com"; int temp = 30;%><%--uses an expression to output variables and constants--%>

Output is typically output with an expression without out.println ()

Example 1:

Example 2 slightly

Third, Scriptlet label

Provide <jsp:script></jsp:script>, same as <%%> function

<jsp:script>

Java Scriptelet Code

</jsp:scipt>



The above content reference Javaweb development actual combat Classics (teacher pulpit)

This article is from the "Beyond the Horizon" blog, be sure to keep this source http://udbful.blog.51cto.com/10601869/1683013

01_01 JSP Basic syntax

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.