JSP technology learning summary

1, the execution of JSP

First, the user issues a request to the server, the server after receiving a request to find the page response jsp, jsp page server then translated into .java files, then compiled bytecode obtained .class file, the server executes the class file to convert it into

html stream in response to the client, the client get translated into a further stream html page. At this point the process is finished jsp

Summary: jsp implementation mainly: translation, compilation, execution

2, JSP instruction

The concept: What is JSP instructions, simply put JSP JSP engine instruction is in charge told how to translate the page into jsp servlet, jsp by setting properties to control some of the features jsp page at runtime.

Note: jsp directive <% @ start, end%> by the need to pay attention to that fact in itself is a jsp servlet, it's just a standardized template html code, in essence, is a servlet, jsp is mainly used to make the displayed page

Three instructions are as follows:

(1) page: Page Setup instructions, including the leader packet import, contentType content type, Language scripting language, session, arranged errpage error page, whether the error handling page isErrorPage

(2) include, containing instructions, divided into static and dynamic contains contains, its main function is referenced page has been written htmll

(3) taglib, custom tag library

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" preix="c">

3, JSP in the nine built-in objects

(1) pageContext: the special object, may be acquired eight other objects, other objects eight methods

(2) page: current page, to call the servlet method that can be used

(3) request: Get user's request information

(4) response: the server response to client requests

(5) session: to save the information for each user, stored in a server

(6) application: indicates that the site information, the scope for the site, as long as the server does not shut down, the information will not fail

(7) config: server configuration information, you can obtain initialization parameters

(8) out: used to page output actually getWrite () method

(9) exception: exception information

4, cookie: a user identity of the request, stored in the local in which the session cookie dependent

5, the difference between forward and redirect

Forward: a client request, the server process twice, and transfer of information will not be lost; that is forwarded when the user requests to the server, which can not meet a servlet handle requests, so they call

Another servlet for processing the request, and then process the results returned to the client, the client is just a whole made a request, and the server process twice.

Redirect: Client requests twice, server processing twice. When the server receives the user's request, if it can not satisfy the current request servlet then put the user's request to another servlet processed, then the client will request the servlet, the corresponding servlet will be processed for the user a total request twice, and the server also handles twice.

6, GET and POST difference:

(1) address bar: GET parameter mode displays the requested information in the address bar, but will not display POST

(2) the transmission data size limits: GET data transmission is about 2KB, while POST is not limited as long as enough memory is theoretically can have much

(3) Type of data transmission: GET only ASCII characters are transmitted, while POST is not limited, and may transmit binary

(4) History: Parameters GET request method will be saved in the browser's history, and will not POST

(5) Security: Security is poor GET, POST GET higher compared to

(6) cache: GE be cached, but can not cache POST

7, still included in the difference between dynamic include:

With a dynamic element that contains the page, it has two forms, while still contain only one form, the main difference is that static include is to contain and then compile and dynamic include is the first to be compiled and then be included.

8, EL expressions

(1) The basic three kinds of syntax:

} // {$ expression expression is generally the data transmitted by the server, they will be displayed to facilitate EL expression

The dot operator $ {subject. Property}} // info.name $ {e.g., info is obviously an object, or a collection of objects

[] Operator $ {Object [Properties]} // dot operator with one meaning

9, JSTL (JSP Standard Tag Library)

Java is an official tag library, mainly for the convenience of writing Java code in JSP, making it easier handling duties

Use process:

(1) introducing jar package: jstl.jar and statndard.jar

(2)添加taglib指令:<%@ taglib uri="http://java.sun.com/jsp/jstl/core" preix="c" >

The core tag library

 

Guess you like

Origin www.cnblogs.com/ByteBeat/p/11366823.html