JSP Lesson 1-Introduction to JSP

Source: Internet
Author: User

Statement: most of the content of this courseware comes from Yi xiangyi Zhang yueping, "JSP practical tutorial (2nd )".

1. What is JSP?

JSP (Java Server Pages) is a web application development technology based on the Java language. Using this technology, you can build secure and cross-platform advanced dynamic websites. Today, many famous web sites use JSP technology.
2. installation and configuration of Tomcat server
The computer that installs the JSP Engine is called a web server that supports JSP. The web server that supports JSP is responsible for running JSP and returning the running result to the user.
Tomcat is a free open-source JSP Engine, also known as a Tomcat server. You can log on to http://jakarta.apache.org/tomcatfree to download tomcat5.5
If you download the apache-tomcat-6.0.13.zip file, you only need to extract the ZIP file to a partition on the disk.
If you download apache-tomcat-6.0.13.exe and double-click the apache-tomcat-6.0.13.exe file, the "Installation Wizard" page appears, and you can install it as prompted.

Start Tomcat server
Before starting tomcat, ensure that JDK is installed on the toamcat computer. Here, we install Sun's jdk1.5. When installing jdk1.5, select the installation directory D: \ jdk1.5.
Set the java_home environment variable. For Windows/XP, right-click "my computer" and choose "properties" from the shortcut menu. The "System Properties" dialog box is displayed, click the "advanced" option in the dialog box, and then click the "environment variables" button to add the following system environment variables:
Variable name: java_home; variable value: D: \ jdk1.5.

Execute startup.bator Tomcat 5.exe in the binfolder of the tomcat installation root directory to start the Tomcat server. Executing startup. BAT to start the Tomcat server occupies a MS-DOS window and closing the Tomcat server if you close the current MS-DOS window. We recommend that you use startup. BAT to start the Tomcat server to ensure that the Tomcat server uses the JDK set by the java_home environment variable.

3. JSP pages and service Directories
Assume that the tomcat installation directory is:
E: \ tomcat5.5
Save example00001.jsp on the JSP page:
E: \ tomcat5.5 \ webapps \ Root
In the address bar of the browser, enter:
Http: // 127.0.0.1: 8080/example00001.jsp

4. Web Service Catalog
You must save the compiled JSP page file to a web service directory of the Tomcat server. Only in this way can remote customers access the JSP page on the Tomcat server through a browser.
Root directory: e: \ tomcat5.5 \ webapps \ Root
Any sub-directory under webapps can be used as a Web Service Directory
Modify the server. xml file in the conf directory under the Tomcat server installation directory to set the new web service directory.

5. Port Number
8080 is the default port number of the Tomcat server
Modify the main configuration file server. XML in the conf directory of the Tomcat server to change the port number.

6. jsp operating principles
When a JSP page on the server is requested for execution for the first time, the JSP engine on the server first translates the JSP page file into a Java file and compiles the Java file to generate a bytecode file, then execute the bytecode file to respond to the customer's request.

(1) hand over the HTML Tag (static part of the page) in the JSP page to the client's browser for display.
(2) handles JSP tags and sends relevant processing results to the client's browser.
(3) execute the Java program (dynamic part of the JSP page) between "<%" and "%>" and hand the execution result to the client's browser for display.
(4) When multiple customers request a JSP page, the Tomcat server starts a thread for each customer. This thread is responsible for executing the bytecode file in the resident memory to respond to the request of the corresponding customer.

When a JSP page on the server is requested for execution for the first time, the JSP engine on the server first translates the JSP page file into a Java file and compiles the Java file to generate a bytecode file, then execute the bytecode file to respond to the customer's request.

(1) hand over the HTML Tag (static part of the page) in the JSP page to the client's browser for display.
(2) handles JSP tags and sends relevant processing results to the client's browser.
(3) execute the Java program (dynamic part of the JSP page) between "<%" and "%>" and hand the execution result to the client's browser for display.
(4) When multiple customers request a JSP page, the Tomcat server starts a thread for each customer. This thread is responsible for executing the bytecode file in the resident memory to respond to the request of the corresponding customer.
Example 1
Example00001.jsp
<% @ Page contenttype = "text/html; charset = gb2312" %>
<HTML> <body bgcolor = cyan>
<H3> This is a simple JSP page <% Int I, sum = 0;
For (I = 1; I <= 100; I ++)
{Sum = sum + I;
}
%>
<H5> the continuous sum between 1 and 100 is:
<% = Sum %>
<H5>
</Body> <HTML>

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.