[Web design] the fourth week JavaSript

JSP fourth week

A JSP Overview

 meaning:

Java Server Pages, one of the widely used server-side scripting language; (running on the server side  BS structure )

JSP code executed by the server-side JSP engine, and the results in HTML pages sent to the client forms.

JSP page: use the program document prepared by the JSP (extension .jsp).
JSP pages mainly by conventional HTML code and embedded therein Java code. ( Dynamically generated page content)
in a JSP page, may include: HTML code, CSS codes, JavaScript code embedded Java code, instruction identification, operation identification, comments and so on.

 

Two JSP operating principle

1. Web browser sends a request to a page ---> to determine whether the JSP page request (page request is an HTML page: page code directly to the request back to the Web browser)

  ---> Request a JSP page (JSP engine checks whether the request for the first time)

  ---> ①  first request : JSP engine JSP pages on this code into the code Servlet (.java), and then generates a byte code (.class) file to be compiled and executed

   ---> ② is not the first request and has not been modified : JSP engine calls JVM execution has been compiled bytecode files (without recompiling)

---->  and perform results to Web browser display

 

Three script logo

classification:

(1) JSP expression:

Syntax: <% = expression%>
Expression: Java language can be any expression, with the ultimate result will be converted to a string to be output

 

(2)

① claims identities  (life cycle starting from the creation to the server closed end)

Meaning: a globally defined variables or methods in JSP pages (JSP page can be accessed throughout)

Syntax: <code% declare a variable or method%!>

<!%
    Int NUM = 0;    // global variable 
   int Check () {     // global method 
       NUM ++ ;
        return NUM; 
   }
 %>

 

 

② snippet (life cycle is created from the beginning to the page is closed, after closing will be destroyed)

Meaning: JSP pages embedded Java code or script code (page during processing of the request is performed).
By Java code can define a variable flow control statements or the like;
by script code JSP built-in objects can be applied to the output content on a page, requests and responses, and so access session.
Syntax:
   <% the Java code or script code%>

(3) script

 

Four page instruction

1. Meaning: specify the relevant properties for the entire JSP page

2. syntax: <% @ 1 Page attribute name = "attribute value 1" 2 attribute name = "attribute value 2" ...%>

3. Common attributes:

(1) language attribute
is used to specify the language used in the JSP page, currently only supports Java language.

例如:
       <%@ page language="java"%>

 

(2) import property
is used to specify packet class to import JSP page (page for embedded Java code or calls).

例如:
<%@ page import="java.util.Date" %>

(3) session attribute
to specify whether JSP pages using HTTP session (session) objects. The default value is true.

For example:
      <% @ = the session Page "to false"%>

(. 4) the pageEncoding attribute
specifies the JSP page encoding format, document encoding (character set). To support Chinese, generally set the property GBK or UTF-8.

For example:
       <% @ Page the pageEncoding = "UTF-. 8"%>

(. 5) contentType attribute
specifies the JSP page MIME type and character encoding, the client browser will display the web page content based on the attribute.

例如:
      <%@ page contentType  =  "text/html;  charset=utf-8"%>

......

 

五 包含指令

1.

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/zyddd915/p/12526422.html