"JSP Basics" (1) JSP basic syntax

Source: Internet
Author: User
Tags html comment

1. JSP directives:

(1). page directive: Usually at the top of a JSP page, the same page can have multiple page directives

Syntax: <%@ page Property 1 = "Property Value" Property 2 = "Property value 1, property value 2"%>

Common Properties:

Language: Specifies the scripting language used by the JSP page; default value: Java

Import: Use this property to refer to the class file used in the scripting language; Default value: None

ContentType: Used to specify the encoding method used by the JSP page; default value: Text/html, iso-8859-1

(2). include directive: Embed an external file into the current JSP file and parse the JSP statements in this page

(3). taglib directive: Use tag Library to define new custom tags and enable custom behavior in JSP pages


2. JSP Comments:

HTML comments:

<!--html comment-->: client visible

JSP comments:

<%--JSP comment-->: Client not visible

JSP script Comments:

Single-line Comment: Client not visible

/**/Multi-line Comment : Client not visible


3. JSP script: <% java code%>

JSP declaration: <%! Java Code%>

JSP expression: <%= expression%>

Note: An expression does not end with a semicolon.

A method can only be declared in a declaration, a variable defined in the script is a local variable, and the variable defined in the declaration is a global variable.


4. Two ways to do the 99 multiplication table for JSP:

<% @page import= "java.io.IOException"%><%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >





"JSP Basics" (1) 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.