A summary of JSP

Source: Internet
Author: User
Tags closing tag

The first chapter:
JSP technology is not only the advanced technology of developing web application, but also the foundation of further learning related technology.
The JSP engine is a Web container that supports JSP programs, is responsible for running jsps, and sends the results to the Client. One of the currently popular JSP engines is tomcat.
Install the Tomcat server, install the JDK first, and you need to set the Java_home environment Variable.
The JSP page must be saved in the Web service directory. A service directory other than the WebApps of the Tomcat server, as the Web service catalog, must be modified by the Tomcat server
Under the Conf folder, server.xml file, and restart the Tomcat Server.
When a JSP page on the server is executed on the first request, the JSP engine on the server first interprets the JSP paging file as a Java file, and then the Java file
Compiles a bytecode file and then responds to the customer's requirements by executing a bytecode file.
When a client requests a JSP page, the Tomcat server initiates a thread for each client that executes the Memory-resident bytecode file in response to the customer
The Request. These threads are managed by the Tomcat server, which quickly switches the use of the CPU between threads to ensure that each thread has the opportunity to execute bytecode
Thing

Chapter Two:
A JSP page can consist of common HTML tags, JSP tags, declaration of member variables and methods, Java patches, and Java expressions. The JSP engine takes the HTML
tag from the JSP page to the Client's browser to perform the display; the JSP engine handles JSP tags, variables and method declarations, The JSP engine is responsible for running the Java patch, computes the Java expression,
and sends the results that need to be displayed to the Client's browser. The member variables in the
JSP page are variables shared by all customers, Java patches can manipulate member variables, and any User's results for JSP page member operations will be shadow
to other Customers.
If multiple users access a JSP page, the Java patches in the page are executed multiple times, running in separate threads, running in different time slices
. The local variables of Java patches running on different threads do not interfere with each other, that is, a user changes the value of a local variable in a Java patch, which does not affect other local variables that are used by the
Client's Java program. The
Page directive is used to define some properties of the entire JSP page and the values of those Properties. The more common two properties are contenttype and Import. The page directive can only specify a value for the
contenttype, but it is possible to specify multiple values for the import Property. The
include directive token is the file to be processed when compiling the cut, the processed file is logically and syntactically dependent on the current JSP page, with the advantage that the page execution speed
is fast, and that the include action tag processes the file while the JSP page is Running. The processed files are logically and syntactically independent of the current JSP page, and the advantage is that you can use the
param child tags to handle the required files more flexibly.


Chapter III
An HTTP communication protocol is a communication protocol between a client and a server that submits information and responds to information (request/response). In jsp, the built-in object request encapsulates the
The information submitted by the Customer. The request object gets the most common method of user-submitted information when GetParameter (String s). Built-in object response object to customer
Request to send data to the client in a dynamic Response.
The HTTP protocol is a stateless Protocol. A customer makes a request to the client, and then the server returns a response (response), and the connection is Closed. So
, the Tomcat server must log information about the connection using the built-in Session object (session). The same client in a Web service directory is the same session, the same
A client's session in a different Web services directory is different, and the sessions of different users are not the Same.
The lifetime of a session object for a user in a Web server directory depends on whether the user closes the browser and whether the session object calls the Invalidate () party
Method makes the session invalid or whether the session object has reached the longest "daze" state time Set.
The built-in object application is created by the server, each of the application objects under the Web Services directory is accessed by all of the users of the service directory, different web
The application in the directory are Different.


The fourth Chapter:
JavaBean is a reusable software component, a class that is written in the Java language following a certain standard, which is called a Javabean.
A JSP page can assign data processing to one or several beans, just call the Bean in the JSP Page. Invoking a bean in a JSP page can
The processing code of the data is separated from the page, the code is reused, and a Web application is maintained more effectively.
The Bean's declaration period is Page,request,session,applcation.


The fifth Chapter:
The point of the input stream is called the source, and the program reads the data from the source into the input stream that points to the Source. and the direction of the output stream is the destination where the data goes, and the program writes to the output stream
The data sends the information to the Destination.
FileInputStream and FileReader streams sequentially read the file, as long as the stream is not closed, each time the Read method is called reads the remainder of the source sequentially until the Source's
The end or stream is Closed. The difference is that the FileInputStream stream reads the file in bytes (byte); FileReader reads the text in characters (char)
Thing
Fileoutstream and FileWriter write the file sequentially, as long as the stream is not closed, each time the writer method is called to write the content to the output stream until the stream is Closed.
The difference is that the Fileoutstream stream writes the file in bytes (byte), while the FileWriter stream writes the file in characters (char).

The point of the Ramdomaccessfile stream can be either as a source or as a destination, where a read-write file can be called by the Seek method to change the Read-write Location.

Sixth:
JSP interacts with the API and database provided by JDBC. JDBC Technology plays an important role in database development, and JDBC operates on different databases with only
differences in connection Mode. Once a jdbc-based application is connected to the database, the database can be manipulated using the API provided by JDBC. There are two common ways to establish a connection between a
JDBC and a database: to establish a JDBC-ODBC bridge and load a pure Java database driver, regardless of which heatstroke connects to the database,
does not permanently manipulate the logical code of the Database. The idea of a
database connection pool is that the Tomcat server can pre-prepare connection objects for several databases, place them in a container that is called a connection pool, and
when a customer needs to manipulate the database, simply remove a connection object from the connection pool, When the user finishes using the connection object, put the connection object back into the connection pool, and
cannot close the connection to the database when querying the data in the result Object. The
Cachedrowsetimpl object can hold the data in the ResultSet object, and the data in the Cachedrowsetimpl object does not depend on the connection object, so the query
When you cachedrowsetimpl data in an object, you can close the connection to the Database.
using PreparedStatement objects can improve the efficiency of the operational database.

Seventh:
The core idea of the Java servlet is to create the appropriate User-requested object on the server Side.
If the Web server directory needs to create a servlet object, you need to establish the corresponding subdirectory in the Web service directory, such as the servlet Class's
, based on the package name of the servlet class. Package name star.moon, The subdirectory Web-inf\classes\star\moon is established under the Web service directory.
The first time a Servlet object is requested to load yes, the server creates a Servlet object that calls the Init method to do the necessary initialization work, and the Init method is called only once by the
Servlet object when the subsequent When the client requests the Servlet object service, the server starts a new thread in which the Servlet object calls the
Service method to respond to the Client's Request. Each request from each client causes the service method to be called to execute, and the calling procedure executes in a different thread and does not interfere with each other. The service method that the
Servlet class inherits examines the HTTP request type (get,post, etc.) and, in the service method, calls the Doget or
Dopost method accordingly, Depending on how the user requests it. therefore, the servlet class does not have to rewrite the service method to directly inherit the method, and can override the Dopost or Doget method in the Servlet class in response to a request with the
User. The
RequestDispatcher object can forward a User's request to the current JSP page or servlet to another JSP page or servlet, and the user to the current JSP page
The requests and responses (httpservletrequest objects and HttpServletResponse objects) of the polygon or servlet are passed to the forwarded JSP page or Servlet. That is
, the target page or Servlet object that the current page is forwarding to can use request to get the data submitted by the User.

The eighth Chapter:
The core idea of the MVC pattern is the effective combination of "view" "mode" and "controller". In JSP technology, A view is one or more JSP pages whose job is primarily to control
The system submits the necessary data and provides the data display for the model; a model is one or more JavaBean objects used to store data; a controller is one or more Servlet objects
, the data is processed according to the requirements submitted by the rabbit, and the results are stored in javabean, and the servlet requests a JSP in the view using the Redirect method
Page updates are Displayed.
In the MVC pattern, the model is created and initialized by the Controller.

The Nineth chapter:
An XML file is a text file that is composed of tokens. The XML file has only one root tag, and the other tokens must be encapsulated in the root tag. The tag of the file must be a tree-type structure,
A non-empty tag must consist of a start tag and an end tag, and the empty tag has no start tag and closing Tag.
DOM parser organizes data in memory by Tree structure, DOM Parser creates a "tree" in memory by reading XML files, tags of xml files, tagged text content
will correspond to a node in the "tree" in Memory.
The SAX parser generates the corresponding event based on the data parsed from the file and reports the event to the event handler, which processes the discovered Data.
By linking an XML file with a CSS style sheet file, You can easily display the text contained in the markup in the XML file.

A summary of JSP

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.