First, the related software introduction
1, J2SDK:JAVA2 software development tools, is the basis of Java applications. JSP is based on Java technology, so you must install J2SDK before you configure the JSP environment.
2, Apache server: Apache organization developed a common Web server, to provide Web services.
3. Tomcat server: A JSP engine developed by Apache, which itself has the function of a Web server, can be used as a standalone Web server. However, as a Web server, tomcat processing static HTML pages is not as fast as Apache, nor Apache robust, so we generally use Tomcat with Apache, let Apache to the site's static page request service, Tomcat, as a dedicated JSP engine, provides 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 great choice.
4, Mod_jk.dll:Apache organization Jakarta Project team developed to enable Apache support Tomcat plug-in. With this plugin, Tomcat can seamlessly connect with Apache.
5, Tc4ntiis.zip:Apache organization Jakarta Project team developed a plug-in that enables IIS to support Tomcat.
Second, software download
1, J2SDK
Version: j2sdk1.4.1 (36.31MB)
Address: http://java.sun.com/j2se/1.4.1/download.html
2, Apache2
Version: Apache2.0.43 (9521KB)
Address: http://www.mydown.com/soft/194/194610.html
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 nectors/jk/release/
5, Tc4ntiis.zip (220KB)
Address: Http://members.ozemail.com.au/~l/iisnt/tc4ntiis.zip
The above are free software.
Third, the preparation before the configuration
(i) Preparation of a test JSP Web page
Open a text editor, such as Notepad, enter the following code and save as test. JSP (note the extension is. jsp).
<HTML>
<HEAD>
<TITLE> JSP test Page </TITLE>
</HEAD>
<BODY>
<%out.println ("</BODY>
</HTML>
(ii) Installation of J2SDK
Either way, you must complete the J2SDK installation before you install and configure the JSP engine.
1, installation J2sdk
Under Windows, run the downloaded J2sdk-1_4_1_01-windows-i586.exe file directly, install it to a directory according to the installation wizard, such as installing to F:\J2SDK 1.4.1;
2. Add Environment variables
(1) If your operating system is Win98, you can edit the Autoexec.bat directly with Notepad 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\lib\tools.jar
After saving, restart the computer so that the environment variables you add will be valid.
(2) If your operating system is Win2000, then according to the road, such as the foot of the fatty song June s one browsing? "in the pop-up menu, select" Properties "→" System Properties "→" Advanced "→" Environment variables ", the Environment Variables dialog box, you can edit the system environment variables. Add the path, Java_home, and classpath three variables, the value of the variable as above.
Iv. configuration scheme of JSP environment
(i) Programme I: J2sdk+tomcat
In this scenario, Tomcat is both a JSP engine and a Web server, and the configuration is relatively straightforward.
1. Install Tomcat
Run the downloaded Jakarta-tomcat-4.0.1.exe directly, install Tomcat in accordance with the usual Windows program installation steps, and it will automatically look for the J2SDK location when you install it. For example, install to F:\TOMCAT4.
2. Configuring Tomcat's environment variables
Add a new environment variable tomcat_home, the variable value is F:\TOMCAT4, add the method with the J2SDK environment variable configuration method.
3. Test default Service
After the setup is complete, you can run the Tomcat server. Start Tomcat with F:\tomcat4\bin\startup.exe and close with F:\tomcat4\bin\shutdown.exe. (If you are prompted for an out of environment space error when executing startup.exe or Shutdown.exe, select "Properties" → "Memory" → "General memory" in the DOS window's menu to change "initial environment" from "Auto" to "2816" You can do it. )
After you start Tomcat, open the browser, enter http://localhost:8080 in the Address bar (tomcat default port is 8080), and if you see the Tomcat Welcome screen in the browser, it means that Tomcat is working properly.
4. Test Project
Put the test.jsp you just prepared in the f:\Tomcat\webapps\examples\jsp directory, enter http://localhost:8080/examples/jsp/test.jsp in the Address bar, if the browser displays "Hello world! ", the configuration of your JSP environment is successful!
Because Tomcat itself has the functionality of a Web server, we don't have to install Apache, and of course it can be integrated with Apache, as described below.
(ii) Programme II: J2SDK+APACHE+TOMCAT
Although Tomcat can also be a Web server, it does not handle static HTML as much as Apache, and its function as a Web server is far inferior to Apache, so it integrates Apache and Tomcat and uses Apache as a Web server. And Tomcat is a dedicated JSP engine. The configuration of this solution is complex, but it allows Apache and Tomcat to be perfectly integrated for powerful functions.
Note that because the IIS Web server uses 80 ports by default, and Apache's default port is also 80, if you are using the Win2000 operating system and IIS is preinstalled, it is convenient to stop the IIS service before you do the following.
1. Installing Apache
Run the downloaded Apache_2.0.43-win32-x86-no_ssl.exe, and follow the wizard to install to F:\Apache2. (Note that after the Apache2.0.43 installation succeeds, you must rename the Index.html.en in the F:\Apache2\htdocs directory to index.html so that the Apache welcome interface is displayed normally when you test the default service).
2. Test Apache default Service
Once installed, the Apache server is already running automatically. Open the browser, enter in the Address bar: http://localhost (tomcat default port is 80), if you see the Apache welcome interface in the browser, the Apache is working properly.
3. Install Tomcat as per the steps of scenario one and make sure it runs normally.
4. Copy the downloaded Mod_jk-2.0.42.dll to the F:\Apache2\modules directory.
5, the establishment of MOD_JK module work required working documents.
Open a text editor and enter the following statement:
WORKERS.TOMCAT_HOME=F:\TOMCAT4 (Let MOD_JK module know Tomcat)
workers.java_home=f:\j2sdk1.4.1 (Let mod_jk module know JSDK)
Ps=\
WORKER.LIST=AJP13 (module version of MOD_JK)
worker.ajp13.port=8009 (MOD_JK's working port)
Worker.ajp13.host=localhost
Worker.ajp13.type=ajp13
Worker.ajp13.lbfactor=1
Save the above 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 with a text editor
1) Find "DirectoryIndex" and add index.jsp after Index.html.var;
2) Add the following code at the end of the httpd.conf (explained in parentheses)
LoadModule Jk_module Modules/mod_jk-2.0.42.dll
(Load MOD_JK module for handling Apache and Tomcat connections)
Jkworkersfile "F:/tomcat4/conf/workers.properties"
(Indicates the location of the working file Workers.properties required for the MOD_JK module to work)
jkmount/servlet/* ajp13
Jkmount/*.jsp ajp13
(Send all servlet and JSP requests through AJP13 's protocol to Tomcat for Tomcat to handle)
3) Save after the addition is complete.
7. Configuring Tomcat
Open F:\Tomcat4\conf\server.xml with a text editor. Because TOMCAT4 does not enable AJP13 by default, the following code is found:
!--
<connector classname= "Org.apache.ajp.tomcat4.Ajp13Connector"
Port= "8009" minprocessors= "5" maxprocessors= "0" acceptcount= "ten" debug= "/"
-->
By deleting the annotation symbol!----, you can enable AJP13.
Then save, now the integrated configuration of Tomcat and Apache is basically complete.
8. Overall Test
Put the test.jsp in the f:\Tomcat\webapps\examples\jsp directory and start apache2,tomcat4 in turn. Open the browser and enter http://localhost:8080/examples/jsp/test.jsp in the address bar if "Hello world!" appears in the browser ", then tomcat works fine, enter http://localhost/examples/jsp/test.jsp in the Address bar, and http://localhost:8080/examples/jsp/ The test.jsp results are the same, which indicates that Apache and Tomcat have been integrated successfully!
(iii) Programme III: J2SDK+IIS+TOMCAT
The most common Web server under the Windows platform is undoubtedly IIS, which, under normal circumstances, does not support JSP, we can enable IIS to send all JSP requests to Tomcat execution by using an IIS to Tomcat redirect Plug-in. You can make IIS more capable of handling jsps. If you are accustomed to using IIS, you can try this configuration. (If you have already installed Apache server, please uninstall Apache in order to facilitate later operation.) )
1. Install Tomcat as per the steps of scenario one and make sure it runs normally. (e.g. installation to F:\TOMCAT4);
2. Extract the downloaded tc4ntiis.zip directly into the F:\TOMCAT4 directory. Review the files required by the configuration to ensure that they are in the following location:
F:\tomcat4\server\lib\ajp.jar
F:\tomcat4\server\lib\tomcat-util.jar f:\tomcat4\bin\native\isapi_redirect.dllf:\tomcat4\conf\ntiis\ Workers.propertiesf:\tomcat4\conf\ntiis\uriworkermap.propertiesf:\tomcat4\conf\ntiis\iis_redirect.reg
F:\tomcat4\log\iis_redirect.log
3. Open f:\tomcat4\conf\ntiis\workers.properties with 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, but modify Log_file, Worker_file, Worker_mount_ File The key values of these three keys to suit your environment (for example, Tomcat in this article is installed in F:\TOMCAT4 instead of the default C:\TOMCAT4). Added and modified as soon as.
5. Open Internet Services Manager and add a new virtual directory on the default site named Jakarta, which points to f:\tomcat4\bin\native and launches the default site.
6. Right-click the server name in Internet Service Manager, select Properties → edit → ISAPI filter tab of the WWW service in the main property, add an ISAPI filter named Jakarta Redirect, the executable file is specified as F:\ Tomcat4\bin\native\isapi_redirector.dll. After you add an ISAPI filter, the status of Jakarta redirect is a red downward arrow that restarts the IIS service and turns into a green arrow.
7. Edit the Server.xml file and save it (7th step with program two).
8. Restart IIS and Tomcat.
9, the test project: Put test.jsp in the f:\Tomcat\webapps\examples\jsp directory. Open the browser and enter http://localhost:8080/examples/jsp/test.jsp in the address bar if "Hello world!" appears in the browser ", then tomcat works fine, enter http://localhost/examples/jsp/test.jsp in the Address bar, and http://localhost:8080/examples/jsp/ The test.jsp results are the same, which means that IIS and Tomcat are integrated successfully!
V. Concluding remarks
Set up the JSP running environment is the basis of learning JSP technology, JSP engine a lot of types, configuration methods are also many, and the software version is constantly upgrading, we can according to their own needs and actual situation to choose the appropriate configuration method. It is hoped that this paper gives some JSP environment configuration scheme, which is helpful to the people who want to learn JSP.
Tomcat, Apache, IIS, three Web servers to tell the 3 ways to build a JSP run environment