SoFunction
Updated on 2025-04-10

Detailed method for configuration of JSP dynamic website development environment


4. Configuration plan of JSP environment

(I) Solution 1: J2SDK + Tomcat

In this solution, Tomcat is both a JSP engine and a web server, and the configuration is relatively simple.

1. Install Tomcat

Directly run the downloaded jakarta-tomcat-4.0. and follow the general Windows program installation steps to install Tomcat. It will automatically find the location of the J2SDK during installation. For example, install to f:\tomcat4.

2. Configure the environment variables of Tomcat

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

3. Test the default service

After the setup is complete, you can run the Tomcat server. Start Tomcat with f:\tomcat4\bin\ and close with f:\tomcat4\bin\. (If you prompt an Out of Environment Space error when executing or, select "Properties" → "Memory" → "General Memory" in the menu of the DOS window, and modify the "Initial Environment" from "automatically" to "2816".)

After starting Tomcat, open the browser and enter http://localhost:8080 in the address bar (Tomcat default port is 8080). If you see the Tomcat welcome interface in the browser, it means that Tomcat is working normally.

4. Test items

Put the prepared ones just now in the directory f:\Tomcat\webapps\examples\jsp, enter http://localhost:8080/examples/jsp/ in the address bar. If "Hello World!" is displayed in the browser, it means that your JSP environment has been configured successfully!

Since Tomcat itself has the function of a web server, we don't have to install Apache, of course it can also be integrated with Apache, as described below.

(II) Solution 2: J2SDK + Apache + Tomcat

Although Tomcat can also be used as a web server, its speed of processing static HTML is not as fast as Apache, and its function as a web server is far less than Apache. Therefore, it integrates Apache and Tomcat, uses Apache as a web server, and Tomcat as a dedicated JSP engine. The configuration of this solution is relatively complex, but it can perfectly integrate Apache and Tomcat to achieve powerful functions.

Note that because the IIS web server uses port 80 by default, and Apache's default port is also 80, so if you are using the Win2000 operating system and IIS is pre-installed, please stop the IIS service before performing the following operations.

1. Install Apache

Run the downloaded apache_2.0.43-win32-x86-no_ssl.exe and follow the wizard to install it to f:\Apache2. (Note that after Apache2.0.43 is installed successfully, the name under f:\Apache2\htdocs directory must be renamed to, so that the Apache welcome interface will be displayed normally when testing the default service).

2. Test Apache default service

After installation, the Apache server is running automatically. Open the browser and enter: http://localhost (Tomcat default port is 80). If you see Apache's welcome interface in the browser, it means that Apache is working normally.

3. Install Tomcat according to the steps of Scheme 1 and ensure it is running normally.

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

5. Create the working files required for the mod_jk module work.

Open the text editor and enter the following statement:

The following is the quoted content:

workers.tomcat_home=f:\tomcat4 (let the mod_jk module knows Tomcat)

workers.java_home=f:\j2sdk1.4.1 (Let the mod_jk module knows about JSDK)

ps=\

=ajp13 (module version of mod_jk)

worker.=8009 (mod_jk's working port)

worker.=localhost

worker.=ajp13

worker.=1

Save the above statement as the file name in the directory f:\Tomcat4\conf (note: the file extension is .properties).

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

1) Find "DirectoryIndex" and add it later;

2) Add the following code at the end (explained in brackets)

The following is the quoted content:

LoadModule jk_module modules/mod_jk-2.0.

(Load mod_jk module to handle connections between Apache and Tomcat)

JkWorkersFile "f:/tomcat4/conf/"

(Indicate the location of the working files required for the mod_jk module to work)

JkMount /servlet/* ajp13

JkMount /*.jsp ajp13

(Send all servlet and jsp requests to Tomcat through the Ajp13 protocol and let Tomcat handle it)

3) Save after adding.

7. Configure Tomcat

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

The following is the quoted content:

<!--
<Connector className=".tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75" acceptCount="10" debug="0"/>
--> Delete the comment symbol <!-- --> to enable Ajp13.

Then save it, and now the integrated configuration of Tomcat and Apache is basically completed.

8. Overall test

Put it in the f:\Tomcat\webapps\examples\jsp directory, and start Apache2 and Tomcat4 in turn. Open the browser and enter http://localhost:8080/examples/jsp/ in the address bar. If "Hello World!" appears in the browser, Tomcat will work normally after reconfiguring; enter http://localhost/examples/jsp/ in the address bar. If the result is the same as http://localhost:8080/examples/jsp/, it means that Apache and Tomcat have been integrated successfully!

(III) Plan 3: J2SDK + IIS + Tomcat

The most commonly used web server on the Windows platform is undoubtedly IIS. Under normal circumstances, IIS does not support JSP. We can use an IIS to Tomcat redirect plug-in to enable IIS to send all JSP requests to Tomcat for execution, which can make IIS increase the function of handling JSP. If you are used to using IIS, you can try this configuration. (If you have installed Apache server, please uninstall Apache first for easier subsequent operations.)

1. Install Tomcat according to the steps of Scheme 1 and ensure it is running normally. (For example, install to f:\tomcat4);

2. Decompress the downloaded one directly to the f:\tomcat4 directory. Check the files required for the configuration and make sure they are in the following locations:

f:\tomcat4\server\lib\

f:\tomcat4\server\lib\ f:\tomcat4\bin\native\isapi_redirect.dll f:\tomcat4\conf\ntiis\ f:\tomcat4\conf\ntiis\ f:\tomcat4\conf\ntiis\iis_redirect.reg

f:\tomcat4\log\iis_redirect.log

3. Open f:\tomcat4\conf\ntiis\ with a text editor and modify the following values ​​to:

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, but 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, the following figure is shown below.

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

6. Right-click the server name in the Internet Service Manager, select "Properties" → "Edit" → "ISAPI Filter" tab of "WWW Service" in the main attribute, add an ISAPI filter with the name Jakarta Redirect, and specify the executable file as f:\Tomcat4\bin\native\isapi_redirector.dll. After adding the ISAPI filter, the status of Jakarta Redirect is a red downward arrow. If you restart the IIS service, it will turn into a green arrow.

7. Edit the file and save it (Step 7 of the same plan 2).

8. Restart IIS and Tomcat.

9. Test project: Put it in the f:\Tomcat\webapps\examples\jsp directory. Open the browser and enter http://localhost:8080/examples/jsp/ in the address bar. If "Hello World!" appears in the browser, Tomcat will work normally after reconfiguring; enter http://localhost/examples/jsp/ in the address bar. If the result is the same as http://localhost:8080/examples/jsp/, it means that the integration of IIS and Tomcat has been successful!

V. Conclusion

Building a JSP running environment is the basis for learning JSP technology. There are many types of JSP engines, many configuration methods, and the software version is constantly being upgraded. You can choose the appropriate configuration method according to your needs and actual situation. I hope that the several JSP environment configuration schemes given in this article will be helpful to those who want to learn JSP.