JSP Java Server Page, jspjava Server

Source: Internet
Author: User
Tags html comment

JSP Java Server Page, jspjava Server

Hello everyone! Long time no see! Today, we started to learn about JSP. Here we will share some basic record knowledge with you.

 

First, let's talk about the URL (Uniform Resource Locator agrees to the Resource Locator ).

  

The URL includes the transmission protocol (http: //), IP address, port (if the port is 80, it can be omitted; otherwise, it cannot be omitted), and project resource address.

 

Let's talk about the B/S and C/S architectures.

B/S is a browser/server;

The browser interacts with the server in the request/mode;

The B/S structure is an improvement of the C/S structure;

When the application is in the B/S structure, the program is deployed on the application server and communicates with the database server through the Application Server. No files need to be installed on the client, the system interface is implemented through a browser;

The B/S structure is based on the Internet, so the access range is larger than that of C/S.

C/S is the Client/Server.

B/S is easier to maintain and upgrade.

 

Let's talk about Tomcat. Open-source project of Apache Jakarta, JSP/servlet container, and web container. When Java is used for Web programming, it must be published to the Web container to run.

After Tomcat is installed, the default port is 8080;

Documentation programs can be provided to browsers that send requests;

Provides information browsing services on the Internet.

Directory structure of the Tomcat server:

/Bin directory: stores script files used to start and stop Tomcat on various platforms;

/Conf directory: stores various configuration files of the Tomcat server;

/Lib directory: stores various JAR files required by the Tomcat server;

/Logs: stores Tomcat log files;

/Temp: used to store temporary files during Tomcat running;

/Webapps: When a Web application is published, the Web application files are stored in this directory by default;

/Work: Tomcat defends the Servlet generated by JSP against this directory.

Directory structure of the Web project:

/: Root directory of the Web application. All files under this directory can be accessed on the client (JSP, HTML, etc );

/WEB-INF: store the various resources used by the application, the directory and its sub-directories are not accessible to the client;

/WEB-INF/classes: stores all class files for Web projects;

/Web-INF/lib: stores JAR files used by Web applications.

When you develop a web project using JSP, the web. xml file is located under the WEB-INF directory.

To manually deploy a Web application, follow these steps:

1. Compile the Web application code;

2. Create an application file directory under the webapps directory;

3. Copy the created page to the application directory;

4. Start and access the Tomcat service.

JSP execution process:

1. Translation phase: compiled JSP files are first converted into Java source code by the JSP engine in the web container;

2. compilation phase; Java source code will be compiled into executable bytecode;

3. Execution phase. After receiving the request from the client, the container executes the JSP file compiled into bytecode. After the request is processed, the container returns the generated page to the client for display.

  

 

JSP (Java Server Pages, a Java-language Server Page Technology): embedded Java script code in HTML.

Three annotations of JSP:
HTML comment (this comment is displayed when you view the source code on the webpage ):
<! -- Html comment -->
JSP annotation (This annotation is not visible when the source code is viewed on the webpage ):
<% -- JSP comment -- %>
Comment in the JSP script (this comment is not visible when you view the source code on the web page ):
<% // Single line comment %>
<%/* Multi-line comment */%>

JSP page elements:

Static content: HTML static text;

Command: starts with "<% @" and ends with "%">

Small Script: <% Java code %>

Expression: <% = Java expression %>

Declaration: <%! Method %>

JSP built-in objects are a group of objects created by Web containers and a group of class instances.

Common JSP built-in objects:

Out -- output statement

Request -- Process client requests

Response -- client request

Session: the session object. A session refers to a request and a response.

You can keep the session information of each user, save your data for different users, and store the data on the client.

Application -- application

In fact, JSP is a Servlet and runs on the server. After dynamic compilation in the background, the client finally wants to output common html code, which needs to be run in a Tomcat-like servlet container. Java code can be embedded in the JSP file.

Forwarding and redirection:

Forwarding: the forwarding function plays a role on the server. The forward method is used to transfer the submitted information among multiple pages;

The address bar of the client browser does not display the redirection address.

Redirection: the customer is dedicated to redirect the page by requesting a new address;

You can view the redirection address in the address bar.

The above is only my opinion. If there are differences, you can raise them and make progress together!

 

    

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.