JSP entry-level website environment setup steps

Source: Internet
Author: User

JSPJava Server Pages introduced by Sun is a dynamic web page development technology executed on the Server, which is based on Java technology. When executing JSP, you need to set up an engine for compiling JSP Web pages on the Web server. You can configure the JSP environment in multiple ways, but the main task is to install and configure the Web server and JSP Engine.

The following uses Tomcat as the JSP Engine and uses Tomcat, Apache, and IIS as the three Web servers to describe how to build a JSP running environment.

I. software required for getting started with JSP

1. J2SDK: the software development tool of Java2, which is the basis of Java applications. JSP is based on Java technology, so you must install J2SDK before configuring the JSP environment.

2. Apache server: a common Web server developed by Apache to provide Web services.

3. Tomcat server: a JSP engine developed by Apache. It has the Web server function and can be used as an independent Web server. However, as a Web server, Tomcat does not process static HTML pages as quickly as Apache, nor is Apache robust. Therefore, we generally use Tomcat with Apache, apache provides services for website static page requests, while Tomcat, as a dedicated JSP Engine, provides JSP parsing for better performance. Tomcat itself is a sub-project of Apache, so Tomcat provides powerful support for Apache. Tomcat is a good choice for beginners.

4. mod_jk.dll: Developed by the Jakarta project team of Apache to support Tomcat plug-ins. With this plug-in, Tomcat can be seamlessly connected to Apache.

5. tc4ntiis.zip: Developed by the Jakarta project team of Apache to enable IIS to support Tomcat plug-ins.

Ii. JSP entry software download

1. j2sdk Webjx. Com

JSP entry version: j2sdk1.4.1 (35.9 MB)

Address: http://java.sun.com/j2se/1.4.1/download.html


2. Apache2

JSP entry version: Apache2.0.436.69MB) Address: http://www.apache.inetcosmos.org/dist/httpd/binaries/win32/

3. Tomcat4

JSP entry version:

Address: http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/



4. mod_jk.dll: (136KB)

Address: http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk/release/

5366tc4ntiis.zip 220KB)

Address: http://members.ozemail.com.au /~ Lampante/howto/tomcat/iisnt/tc4ntiis.zip

3. Preparations before JSP entry Configuration

1) Prepare a JSP webpage for testing

Open a text editor, such as Notepad, enter the following code, and save it as test. jsp. Note that the extension is. jsp ).

Reference content is as follows:

  1. <HTML>
  2. <HEAD>
  3. <TITLE> JSP test page </TITLE>
  4. </HEAD>
  5. <BODY>
  6. <% Out. println ("
  7. </BODY>
  8. </HTML>

2) install J2SDK

In either case, you must install J2SDK before installing and configuring the JSP Engine.

1. Install J2SDK

Run the j2sdk-00004_000001-windows-i586.exe file in windows and install it in a directory according to the installation wizard, for example, f: \ j2sdk 1.4.1;

2. Add Environment Variables

1) if your operating system is Win 98, you can use NotePad to directly edit Autoexec. bat and add the following command line:

Reference content is as follows:

PATH = % PATH %; f: \ j2sdk1.4.1 \ bin

SET JAVA_HOME = f: \ j2sdk1.4.1

Set classpath = f: \ j2sdk1.4.1 \ lib \ tools. jar

After saving, restart the computer so that the added environment variables will be valid.

2) If your operating system is Win2000, right-click "my computer ", select "properties"> "system features"> "advanced"> "environment variables" in the pop-up menu. In the displayed environment variables dialog box, you can edit the environment variables of the system. Add three variables: PATH, JAVA_HOME, and CLASSPATH. The variable value is the same as the preceding one.

Iv. configuration scheme of JSP entry Environment

1) solution 1: J2SDK + Tomcat

In this solution, Tomcat serves as both a JSP engine and a Web server, and the configuration is relatively simple. Webpage tutorial Network

1. install Tomcat

Run the downloaded jakarta-tomcat-4.0.1.exe directly and install Tomcat according to the general installation steps of Windows programs. During installation, Tomcat is automatically located in J2SDK. For example, install it to f: \ tomcat4.

2. Configure Tomcat Environment Variables

Add a new environment variable TOMCAT_HOME with the variable value f: \ tomcat4. Add the same method as the J2SDK environment variable configuration method.

3. Test the default service

After setting, you can run the Tomcat server. Start Tomcat with f: \ tomcat4 \ bin \ startup.exe and disable Tomcat with f: \ tomcat4 \ bin \ shutdown.exe. If an Out of Environment Space error is prompted when startup.exeor shutdown.exe is executed, select "attribute" → "Memory" → "regular memory" in the menu of the DOS window ", change "initial environment" from "automatic" to "2816 .)

After Tomcat is started, open the browser and enter http: // localhost: 8080Tomcat in the address bar. The default port is 8080. If you see the welcome interface of Tomcat in the browser, Tomcat works normally.

4. Test Items

Run the test. place jsp in the f: \ Tomcat \ webapps \ examples \ jsp directory, and enter http: // localhost: 8080/examples/jsp/test in the address bar. jsp. If "Hello World!" is displayed in the browser! ", It indicates that your JSP environment has been configured successfully!

Because Tomcat itself has the functions of web servers, we do not need to install Apache. Of course, it can also be integrated with Apache. The following describes. Webpage tutorial Network

Ii) solution 2: J2SDK + Apache + Tomcat

Although Tomcat can also be used as a Web server, its processing speed of static HTML is inferior to that of Apache, and its function as a Web server is far inferior to that of Apache. Therefore, Apache and Tomcat are integrated, use Apache as the Web server, while Tomcat as the dedicated JSP Engine. The configuration of this solution is complicated, but it can perfectly integrate Apache and Tomcat to achieve powerful functions.

Note: Because the IIS Web server uses port 80 by default, and the Apache default port is also port 80, if you are using the Win2000 operating system and preinstalled with IIS, for convenience, stop the IIS service before performing the following operations.

1. install Apache

Run the downloaded apache_2.0.43-win32-x86-no_ssl.exe file and install it to f: \ apache2. Note: After Apache2.0.43 is successfully installed, you must rename the index.html.ename under the f: \ Apache2 \ htdocsdirectory to index.html, so that the Apache welcome interface is displayed normally when the default service is tested ).

2. Test the default Apache service.

After installation, the Apache server runs automatically. Open your browser and enter http: // localhostTomcat's default port is 80 in the address bar. If you see the Apache welcome interface in your browser, Apache works properly.

3. Follow the steps in solution 1 to install Tomcat and ensure its normal operation.

4. Copy the downloaded mod_jk-2.0.42.dll to the f: \ Apache2 \ modules directory.

5. Create a working file required for the mod_jk module.

Open the text editor and enter the following statements:

Reference content is as follows:

Workers. tomcat_home = f: \ tomcat4 let the mod_jk module know about Tomcat)

Workers. java_home = f: \ j2sdk1.4.1 let the mod_jk module know JSDK)

Ps = \
Worker. list = module version of ajp13 mod_jk)

Worker. ajp13.port = 8009 mod_jk working port)

Worker. ajp13.host = localhost

Worker. ajp13.type = ajp13

Worker. ajp13.lbfactor = 1

Save the preceding statement with workers. properties as the file name in the f: \ Tomcat4 \ conf directory. Note: The file extension is. properties ).

6. Configure Apache. Open f: \ Apache2 \ conf \ httpd. conf in a text editor

1) locate "DirectoryIndex" and add index. jsp after index.html. var;

2) Add the following code brackets to the end of httpd. conf.) Webjx. Com

Reference content is as follows:

LoadModule jk_module modules/mod_jk-2.0.42.dll

Load the mod_jk module to process connections between Apache and Tomcat)

JkWorkersFile "f:/tomcat4/conf/workers. properties"

Specifies the location of the workers. properties file required for mod_jk module work)

JkMount/servlet/* ajp13

JkMount/*. jsp ajp13

Send all servlet and jsp requests to Tomcat through the Ajp13 protocol for Tomcat to process)

3) after adding the file, save it.

7. Configure Tomcat

Open f: \ Tomcat4 \ conf \ server. xml in a text editor. Because Tomcat4 does not enable Ajp13 by default, the following code is found:

Reference content is as follows:

  1. <!--  
  2. <Connector className="org.apache.ajp.tomcat4.Ajp13Connector" 
  3. port="8009" minProcessors="5" maxProcessors="75" acceptCount="10" debug="0"/>  
  4. -->  

Annotate the symbol <! --> Delete to enable Ajp13.

Save the configuration. Now the configuration of Tomcat and Apache is complete.

8. Overall Test

Place test. jsp in the f: \ Tomcat \ webapps \ examples \ jsp directory, and start Apache2 and Tomcat4 in sequence. Open your browser and enter http: // localhost: 8080/examples/jsp/test. jsp in the address bar. If "Hello World! ", Tomcat will work normally after reconfiguration. in the address bar, enter http: // localhost/examples/jsp/test. jsp. If it is different from http: // localhost: 8080/examples/jsp/test. if the jsp results are the same, it indicates that Apache and Tomcat are successfully integrated!

3) solution 3: J2SDK + IIS + Tomcat Webjx. Com

The most common Web server on Windows is undoubtedly IIS. Under normal circumstances, IIS does not support JSP. We can use an IIS-to-Tomcat redirection plug-in, enable IIS to send all JSP requests to Tomcat for execution, and enable IIS to process JSP requests. If you are used to IIS, try this configuration. If you have installed the Apache server, uninstall Apache first to facilitate subsequent operations .)

1. Follow the steps in solution 1 to install Tomcat and ensure its normal operation. For example, install it to f: \ tomcat4); Webjx. Com

2. decompress the downloaded tc4ntiis.zip file to the f: \ tomcat4 directory. View the files required for the configuration and make sure they are in the following locations:

F: \ tomcat4 \ server \ lib \ ajp. jar

F: \ tomcat4 \ server \ lib \ tomcat-util.jar f: \ tomcat4 \ bin \ native \ isapi_redirect.dll f: \ tomcat4 \ conf \ ntiis \ workers. properties f: \ tomcat4 \ conf \ ntiis \ uriworkermap. properties f: \ tomcat4 \ conf \ ntiis \ iis_redirect.reg

F: \ tomcat4 \ log \ iis_redirect.log Webjx. Com

3. Open f: \ tomcat4 \ conf \ ntiis \ workers. properties in a text editor and modify the following values:

Workers. tomcat_home = f: \ tomcat4

Workers. java_home = f: \ j2sdk1.4.1

4. Double-click f: \ tomcat4 \ conf \ ntiis \ iis_redirect.reg to add the information in this registration file to the Registry, however, you need to modify the key values of the three keys log_file, worker_file, and worker_mount_file to suit your environment. For example, Tomcat in this article is installed in f: \ tomcat4, instead of the default c: \ tomcat4 ). After adding and modifying, as shown in.

5. Open the Internet Service Manager and add a new virtual directory named jakarta to the default site. The virtual directory points to f: \ tomcat4 \ bin \ native, and start the default site.

6. In Internet Service Manager, right-click the server name and select the "edit"> "ISAPI filter" tab of "properties"> "main attribute" WWW service, add an ISAPI filter named Jakarta Redirect. the executable file is f: \ Tomcat4 \ bin \ native \ isapi_redirector.dll. After the ISAPI filter is added, the Jakarta Redirect status is a red downward arrow. After the IIS service is restarted, it becomes a green arrow.

7. Edit the server. xml file and save step 2 of solution 2 ).

8. Restart IIS and Tomcat.

9. test Project: place test. jsp in the f: \ Tomcat \ webapps \ examples \ jsp directory. Open your browser and enter http: // localhost: 8080/examples/jsp/test. jsp in the address bar. If "Hello World! ", Tomcat will work normally after reconfiguration. in the address bar, enter http: // localhost/examples/jsp/test. jsp. If it is different from http: // localhost: 8080/examples/jsp/test. if the jsp results are the same, the integration of IIS and Tomcat is successful!

V. JSP entry summary

Building a JSP running environment is the basis for learning JSP technology. There are many types of JSP engines and many configuration methods, and the software version is constantly being upgraded, you can select an appropriate configuration method based on your needs and actual conditions. I hope the JSP environment configuration solutions provided in this article are helpful to those who want to learn JSP.

  1. Use of scripts Based on JSP tutorials
  2. JSP tutorial basics-HTML form demonstration
  3. JSP tutorials-basic articles-simple homepage Creation
  4. JSP tutorial basics: Technical Features of JSP
  5. What is JSP and its strong weakness?

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.