"Mooc notes" JSP basic syntax

Source: Internet
Author: User
Tags html comment

JSP Full name: Java Server Pages. Java server-side page.

Essentially a simplified servlet design that enables the use of HTML tags in java. JSP is a dynamic web development standard, like a servlet, executed on the server side.

Common dynamic Website Development technology:

Jsp:java platform, high security, suitable for the development of large, enterprise-class Web applications.

Asp. NET: Based on visual component development, security, cross-platform poor, the best use of Microsoft supporting systems.

PHP: For small and Medium business Web application Development, Gold Development portfolio: linux+apache+mysql+php

JSP basic syntax

JSP three main instruction elements: Import page Taglib

Page instruction Syntax:

<% @page Property 1 = "Property Value" Property 2 = "Property value 1, property value 2" ... Property N= "Property value N"%>

Page directive Common Properties:

Property Describe Default value
Language Specify the scripting language to use for JSP pages · Java
Import Introduce the class file used in the scripting language No
ContentType Specify the encoding used for JSP pages

File type: text/html;

Character encoding: Iso-8859-1

Cases:

 <%@page Language="Java"Import="java.util.*"ContentType="Text/html;charset=utf-8"%>

JSP annotations

HTML comments : comments on the JSP page

<!-- I'm an HTML comment  -  The client is visible and the page does not appear

JSP Comment: <%--jsp comment--%> server-side comment, client not visible

JSP script Comments:

// Single-line comment     
/* Multi-line comments */

JSP script

Java code executed in the JSP page, written in the JSP tag <% Java code%>

Cases:

<%  // single-line comment Out.printlin (" Hello everyone!") "); %>

JSP declaration

Define variables or methods in the JSP page, syntax: <%!java code%>

<%! Strings="Zhang San"; intAdd (intx,intt;) {return x+y;}%>

JSP expressions

Expressions executed in JSP pages, syntax: <%= expressions%>//NOTE: Expressions do not end with semicolons

Cases:

<BR>How are you doing<%=s%></BR>X+y<%=Add (Ten,5)%>  

JSP page life cycle

Phase Project

Printing 99 multiplication tables using expressions and script implementations, respectively

"Mooc notes" 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.