JSP Basics, Scripting __js

Source: Internet
Author: User
Tags html notes

Basis:

One. Introduction to JSP 1. Understanding: Java server page; Embed Java scripting language in HTML
2. Compare servlet and JSP
1 The servlet is suitable for business processing, and JSP is suitable for interface display
2 The JSP file will eventually be converted into a servlet
3. Advantages: Simplify the development of the page
4. Page composition
1 static content (refers to the HTML statement)
2) Instruction <%@ ......%>
3) Expression <%=.......%>
4 Script Fragment <%.......%>
5) Statement <%!.......%>
6 Standard action <jsp: action name ></jsp: Action name >
7) Note:
1.html Notes <!----> (Visible on client)
2.jsp annotation <%----%> (not visible at client, more secure)
The process of 5.JSP pages
1 translate. jsp to servlet (. java suffix name)
2 Compile the servlet into a. Class byte-code file
3) Explanation of execution. class bytecode file
Note: The first time to access a page is slow, the future will be faster


Small Knowledge Points:

Get method Pass parameter format: URL? parameter name 1= value 1& parameter name 2= value 2

Script

One. JSP script elements
1.jsp expression
1) Format: <%= expression%>
Note: The expression here can be: a normal variable, a method that returns a value, a Java expression
2. Declaration of identity
1) Format: <%! Declare the code for a variable or method%>
2) Example
3) Note:
1 in "<%" and "!" No need to add space between
2 The syntax of the declaration is the same as when declaring variables and methods in the Java language
3 in the page through the "Declaration of identity" declared variables and methods, the entire page is valid, they will become the JSP page is converted into the class file properties and methods, and will be multiple threads that multiple users to share
4 The life cycle of a variable or method ends when it is created to a server shutdown
3. Script Fragment
1) Format: <% Java program Fragment%>
2) Example


Two. JSP directives
1. Understanding: You can set properties that are valid throughout the JSP page range
2. Categories:
1) Page Instruction
2) Include directives
3) taglib Instruction
3. Usage
1) page
Format: <%@ page attribute1= "value2" attribute2= "value2" ...%>
Characteristics:
1 can be placed anywhere in the JSP page, but the habit is placed in the beginning of the file, improve the readability of the program
2 A JSP page allows multiple page directives to be used


2) Include directives
Format: <%@ include file= "FileName"%>
Feature: Only the file property is supported, which specifies the file name to embed at compile time




3) taglib Instruction
1) Format: <%@ taglib uri= "tag Library descriptor file" prefix= "prefix name"%>
2) Example:
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
<c:set var= "name" value= "Jack"/>








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.