JSP (Java Server Pages) launched by Sun is a dynamic web page development technology executed on the server side, which is based on Java technology. When executing JSP, an engine that compiles JSP web pages needs to be set up on the Web server. There are many ways to configure the JSP environment, but the main task is to install and configure the Web server and JSP engine.
The following uses Tomcat as the JSP engine and cooperates with the three web servers of Tomcat, Apache, and IIS to describe three solutions for building a JSP running environment.
1. Introduction to related software
1. J2SDK: Java2 software development tool, which is the basis of Java applications. JSP is based on Java technology, so J2SDK must be installed before configuring the JSP environment.
2. Apache server: A commonly used web server developed by the Apache organization to provide web services.
3. Tomcat server: A JSP engine developed by the Apache organization. It has the function of a Web server and can be used as an independent Web server. However, as a web server, Tomcat is not as fast as Apache when processing static HTML pages, and it is not as robust as Apache, so we generally use Tomcat with Apache to let Apache serve static page requests of the website, while Tomcat serves as a dedicated JSP Engine, providing JSP parsing for better performance. And Tomcat itself is a sub-project of Apache, so Tomcat provides strong support for Apache. For beginners, Tomcat is a very good choice.
4. mod_jk.dll: A plug-in developed by the Jakarta project team of the Apache organization to enable Apache to support Tomcat. With this plug-in, Tomcat can seamlessly connect with Apache.
5. tc4ntiis.zip: A plug-in developed by the Jakarta project team of the Apache organization to enable IIS to support Tomcat.
2. Software download
1. j2sdk
version: j2sdk1.4.1 (35.9MB)
address: http://java.sun.com/j2se/1.4.1/download.html
2. Apache2
version: Apache2.0.43 (6.69MB)
address : http://www.apache.inetcosmos.org/dist/httpd/binaries/win32/
3. Tomcat4
version: 4.1.21 (8.33MB)
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/
5. tc4ntiis.zip (220KB)
Address:
all of the above is free software.
3. Preparation before configuration
1. Prepare a JSP web page for testing.
Open a text editor, such as Notepad, enter the following code, and save it as test.jsp (note the extension is .jsp).
<HTML> <HEAD> <TITLE>JSP test page </TITLE> </HEAD> <BODY> <%out.println("<h1>Hello World! </h1>");%> </BODY> </HTML> |
2. Install J2SDK
Regardless of the solution, the installation of J2SDK must be completed before installing and configuring the JSP engine.
To install J2SDK
under Windows, directly run the downloaded j2sdk-1_4_1_01-windows-i586.exe file and install it to a directory according to the installation wizard, for example, install to f:/j2sdk 1.4.1;
add environment variables
1) If your operating system It is Win 98. You can use Notepad to edit Autoexec.bat directly and add the following command line:
PATH=%PATH%;f:/j2sdk1.4.1/bin
SET JAVA_HOME=f:/j2sdk1.4.1
SET CLASSPATH=f:/j2sdk1. 4.1
After saving/lib/tools.jar, restart the computer so that the added environment variables will be effective.
2) If your operating system is Win2000, configure the environment variables as follows. Right-click "My Computer" and select "Properties" → "System Properties" → "Advanced" → "Environment Variables" in the pop-up menu. The environment variables dialog box will pop up, and you can edit the system's environment variables. Add three variables: PATH, JAVA_HOME and CLASSPATH. The variable values are the same as above.
4. JSP environment configuration plan
Plan 1: J2SDK + Tomcat
In this plan, Tomcat serves as both a JSP engine and a Web server, and the configuration is relatively simple.
1. Install Tomcat
and run the downloaded jakarta-tomcat-4.0.1.exe directly. 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 Tomcat's environment variables
and add a new environment variable TOMCAT_HOME. The variable value is f:/tomcat4. The adding method is the same as the configuration method of J2SDK environment variables.
3.
After setting up the test default service, you can run the Tomcat server. Use f:/tomcat4/bin/startup.exe to start Tomcat and use f:/tomcat4/bin/shutdown.exe to shut down. (If an Out of Environment Space error is prompted when executing startup.exe or shutdown.exe, select "Properties" → "Memory" → "Conventional Memory" in the menu of the DOS window and change "Initial Environment" from "Automatic" Just change it to "2816".)
After starting Tomcat, open the browser and enter http://localhost:8080 in the address bar (Tomcat's default port is 8080). If you see Tomcat's welcome interface in the browser, it means Tomcat works fine.