JSP Java Server Page

Source: Internet
Author: User
Tags tomcat server

Hello everyone! Long time no see! Today we began to learn JSP, some of the basic knowledge of the record is here to share with you.

First, the URL (Uniform Resource Locator agree to the resource Locator).

  

The URL includes the Transport protocol (http://), IP address, port (port if 80 can be omitted, others cannot be omitted), project resource address.

Again, the next b/s,c/s architecture.

b/S is a browser/server;

Browser and server side use request/corresponding mode to interact;

b/s structure is a kind of improvement to C/s structure;

When the application Sema is b/s structure, the program is deployed on the application server and communicates with the database server through the application server, without installing any files on the client, and the system interface is implemented by the browser.

b/S structure based on the Internet, so the scope of access than C/s large.

c/S is a client/server.

b/S is simpler from the perspective of maintenance and upgrade.

Say Tomcat again. Apache Jakarta Open Source project, Jsp/servlet container, Web container. When you use Java for Web programming, you need to publish to a Web container to run.

The Tomcat port defaults to 8080 after installation;

A program that can provide documentation to the requesting browser;

Provide information browsing services on the Internet.

The directory structure of the Tomcat server:

/bin directory: A script file for starting and stopping Tomcat under various platforms;

/conf directory: Various configuration files for the Tomcat server;

/lib directory: The various jar files required to store the Tomcat server;

/logs: Log files that store tomcat;

/temp:tomcat runtime is used to store temporary files;

/webapps: When publishing a web app, the Web app's files are stored in this directory by default;

/work:tomcat the servlet generated by the JSP against this directory.

The directory structure of the Web project:

The root directory of the/:web application, where all the files are accessible to the client (JSP, HTML, etc.);

/web-inf: A variety of resources used by the application, the directory and its subdirectories are not accessible to the client;

/web-inf/classes: Store all class files for the WEB project;

/web-inf/lib: Store the jar file used by the Web app.

When developing a Web project using JSP, the. xml file is located in the Web-inf directory.

Steps to manually deploy a Web app:

1. Write code for the Web application;

2. Create the application file directory under the WebApps directory;

3. Copy the created page to the app directory;

4. Start the Tomcat service and access it.

JSP execution Process:

1. Translation stage: The JSP file is first translated into Java source by the JSP engine in the Web container;

2. Compile stage; Java source code will be compiled into executable bytecode;

3. Implementation phase. After the container accepts the client's request, it executes the JSP file compiled into bytecode. After processing the request, the container feeds the generated page back to the client for display.

  

JSP (server-side page technology for Java Server Pages, a Java language): Embed Java script code in HTML.

3 types of annotations for JSPs:
HTML Comments (This comment will be seen when the page is viewing the source code):
<!--HTML comments--
JSP comments (This comment is not visible when the Web page views the source code):
<%--jsp Comment--%>
Comment in JSP script (this comment is not visible when the page is viewing the source code):
<%//single-line comment%>
<%/* Multi-line Comment */%>

JSP page elements:

Static content: HTML static text;

Instruction: Start with "<%@" and End With "%" >

Small script: <%java code%>

Expression: <%=java expression%>

Disclaimer: <%! Method%>

A JSP built-in object is a set of objects created by a Web container, an instance of a set of classes.

Common JSP built-in objects:

Out--Output statement

Request--Processing client requests

Response--Corresponding customer request

Session--Conversation object. A session refers to a request and a corresponding one at a time.

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

Application--Application

The JSP is actually a servlet, running on the server side. After a dynamic compilation in the background, you will eventually want the client to output normal HTML code, which needs to run in a tomcat-like servlet container, where Java code can be embedded in the JSP file.

Forwarding and redirection:

Forwarding: Forwarding is a function on the server side, through the forward method will submit information across multiple pages to pass;

The address bar of the client browser does not show the post-turn address.

Redirect: Redirect The customer to play a role, by requesting a new address to achieve page steering;

You can display the post-turn address in the address bar.

Above only personal views, if there are different, can be proposed, common progress!

    

JSP Java Server Page

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.