[Java Web] 5\jsp (1) Comments & Scriptlet

Source: Internet
Author: User
Tags define local

>_< " supports the syntax of two annotations in JSP, one is explicit annotation, the client is allowed to see, and the other is an implicit comment, which the client is not able to see.
    • Explicit comment Syntax:
<!--comment Content--
    • Implicit comment syntax:
    • Format one://comment, single line comment
    • Format two:/* comment */, multiline comment
    • Format three: <%--comment--%>,jsp Comment
>_< " jsp embedded into the HTML file, JSP is the Java language, in order to embed and effectively hold the need to scriptlet (script applet)."
    • All Java programs that are embedded in HTML code must be marked with Scriplet, with a total of three scritplet codes in the JSP:
    • The first type: <%%>: You can define local variables, write statements in this Scriptlet
    • The second kind: <%!%>: In this scritplet, you can define global variables, methods, classes
    • The third type: <%=%>: Used to output a variable or a specific content
123<title>beautifulzzzz</title>45<body>6<%!7public static final String INFO = "beautifulzzzz";//Defining Global Constants8%>9<%!TenPublicintAddintXintY) {//Defining Methods One                 returnX +y; A             } -%> -<%! theClass Person {//defining the Person class -private String name;//define the Name property -PrivateintAge//defining The Age property -Public person (String name,intAge) {//Setting property content by constructing methods +                      This. name = name;//Assigning a value to the Name property -                      This. Age = Age;//Assigning a value to the Age property +                 } APublic String toString () {//Overwrite ToString () method at                     return"Name =" + This. Name + "; age =" + This. Age; -                 } -             } -%> -<%//write a common scriptlet -Out.println ("//Output Global Constants inOut.println ("//Calling Methods -Out.println ("NewPerson ("Zhangsan", "+") + "//Build Object to%> +  -<% the             intx=10; *String info= "Beautifulzzzz"; $Out.println (");Panax NotoginsengOut.println ("); -Out.println ("//write the output statement directly here the%> + A the +</body> -

This JSP code will be placed in the root directory of its own, and then enter http://localhost/mldn/hello.jsp Run ~

[Java Web] 5\jsp (1) Comments & Scriptlet

Related Article

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.