[Basic Java] first knowledge of JSP and servlet

Source: Internet
Author: User

The recent need to use the Java EE, began to learn about the knowledge of the Java EE.

JSP is a javaserver-side technology that is used to display dynamic content on a Web page.


Tomcat related knowledge
The process of JSP operation
Page composition elements of a JSP
The gaze of a JSP
Static and dynamic include
JSP Standard Tag Library

The nine main built-in objects for JSPs:
Out: A buffered output stream that outputs content to the client
Page: The current JSP page itself, which is an instance of the Java.lang.Object class
Request: Extract the information submitted by the browser
Response:server responds to requests from customers. Sending data to the client
Session: A Conversation object that refers to a conversation between a client and a server
Application: The sharing of data between users, which can hold global variables, starts at server startup until the server shuts down
The pagecontext:jsp page context object provides access to all the objects and namespaces of the JSP page.


Config: configuration information for the corresponding servlet of the JSP
Exception: is an example of throwable. Represents the exception information for a JSP

a servlet is a server-side applet that accepts requests from the network and responds to them.
El expression
JavaBean
The life cycle of the servlet
Classes in the Javax.servlet.jsp.tagext package
Session and Cookie
The basic concept and usage of XML
The process of MVC

JSP and servlet Knowledge Point essence:
the difference between get and POST requests:
Get weaker than post from safe view
Get weaker than post from commit content size
Get stronger than post from response speed
Get call Doget method, Post call Dopost method

the difference between a session and a cookie:
Sessionj Save the information on the server. And the cookie is stored on the client.
Session is more secure than cookie, session is more resource than cookie
The session uses a cookie mechanism
The session is on the service side. Save data to the client via SessionID
The session uses cookies to store client data, so the session relies on cookie
Suppose the browser does not support cookies. Can be implemented by URL rewriting
A cookie can only store string types of data, whereas a session can store data of type object and simple data type

the life cycle of a servlet:
Gta5-In
Instantiation of
Initialization
Processing requests
Exit Service

servlet Context object:
It is a public area that can be shared by all the clients
SetAttribute (): Putting data into public areas
GetAttribute (): Fetching data from public areas

What are the actions of JSP? What are their roles?
JSP together has six basic actions
Jsp:include: Introduce a file when the page is requested
Jsp:usebean: Finding or instantiating a JavaBean
Jsp:setproperty: Setting Properties for JavaBean
Jsp:getproperty: Output Properties of a JavaBean
Jsp:forward: Move the request to a new page
Jsp:plugi: More browser type generates an object or embed tag for a Java plug-in

What is the difference between a dynamic include and a static include in a JSP?
Dynamic include is implemented with the Jsp:include action, which always checks for changes in the contained files. Suitable for including dynamic pages. And can take a number of parameters. Like what:

<jsp:include page="included.jsp"flush="true"/>

Static include is implemented with include pseudo-code, which does not check for changes in the included files, and is suitable for including static pages.

Like what:

<%@file="included.htm"%>

the difference between the include directive and the include action
The include directive is a compile-time syntax. That is, at compile time, the content of the target file pointed to by the instruction is copied to the location of the instruction. The replacement instruction finally forms a file that only has one file at run time.


The include action is the run-time syntax. The file that includes the <jsp:include> action, when running to this label, will turn to the target file that the label runs to, after running the target file, then running the contents of the label, when running, it involves two files, just like the method call.


Used when a piece of code is determined <%@include%> to run, when a piece of code might run <jsp:include> .

What is the difference between a servlet and a JSP?
JSP is compiled to be servlet, also can say JSP equals servlet
JSP is better at page performance. Servlets are better at logic editing (the most important difference).
In practical applications, servlet is used to control business processes, and JSP is used to generate dynamic Web pages. Hey, in the Struts framework, the JSP is in the view layer of MVC design mode, and the servlet is in the control layer.

[Basic Java] first knowledge of JSP and servlet

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.