Sun's JSP (Java Server Pages) is a dynamic web development technology that is executed on server-side, which is based on Java technology. When executing JSP, you need to set up an engine that compiles the JSP web page on the web server. Configuring a JSP environment can have a variety of ways, but main work is to install and configure web servers and JSP engines. Below Tomcat as a JSP engine, with Tomcat, Apache, IIS, three web servers, three ways to build JSP running environments. I. Related software introductions 1, J2SDK: Java2 software development tool is the basis of the Java application. 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 organizations, providing web services. 3, Tomcat Server: Apache organization developed a JSP engine that itself has a web server function, which can be used as a stand-alone web server. However, as a web server, Tomcat is not as fast as Apache, nor Apache, but there is no Apache, so we generally use the Tomcat and Apache to provide services to the website's static page request, while Tomcat is a dedicated JSP Engine, providing JSP parsing to get better performance. And Tomcat itself is a sub-project of Apache, so Tomcat provides strong support to Apache. For beginners, Tomcat is a very good choice. 4, MOD_JK.DLL: Apache Organize the Jakarta project group developed the Apache support Tomcat plug-in. With this plugin, Tomcat can seamlessly connect with Apache. 5, TC4NTIS.ZIP: APACHE Organize the Jakarta project group to develop the IIS support Tomcat plug-in. Second, software download 1, J2SDK version: J2SDK1.4.1 (35.9MB) Address: http://java.sun.com/j2se/1.4.1/download.html 2, 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, TC4NTIS.ZIP (220KB) Address: http: //Members.ozemail.com.au/~lampante/howto/tomcat/iisnt/tc4ntiis.zip is free of charge. Third, preparation before configuration (1) Prepare a Test JSP page to open a text editor, such as Notepad, enter the following code, and save it to test .jsp (notice extension .jsp).
PATH =% path%; f: /j2sdk1.4.1/binset java_home = f: /j2sdk1.4.1set classpath = f: /j2sdk1.4.1/lib/tools.jar
After saving, restart your computer so that the environment variable added is valid. (2) If your operating system is Win2000, then configure environment variables as follows. Right-click My Computer, select "Properties" → "System Features" → "Advanced" → Environment Variables in the pop-up menu, and the Environment Variable dialog box can edit the environment variable. Add three variables in Path, Java_Home and ClassPath, and the variable value.
Fourth, JSP Environment Configuration Scheme (1) Scheme 1: J2SDK Tomcat In this scheme Tomcat as a JSP engine as a web server, the configuration is relatively simple. 1. Install Tomcat to run the downloaded Jakarta-Tomcat-4.0.1.exe, follow the general Windows program installation steps to install Tomcat, which will automatically look for the J2SDK. For example, install it 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 to the configuration method of the J2SDK environment variable. 3. Test the default service settings, you can run the Tomcat server. Start Tomcat with f: /tomcat4/bin/startup.exe, close with f: /tomcat4/bin/shutdown.exe. (If you prompt the Out of Environment Space error while executing Startup.exe or ShutDown.exe, select "Properties" → "Memory" → "General Memory" in the DoS window, and modify the "Automatic" "2816" can be.) After launching Tomcat, open the browser, enter http: // localhost: 8080 in the address bar (Tomcat default port is 8080), if you see Tomcat's welcome interface, Tomcat works fine. 4, the test project puts the Test.jsp just ready to be in the F: / Tomcat / WebApps / Examples / JSP directory, enter http: // localhost: 8080 / examples / jsp / test.jsp in the address bar, if browse "Hello World!" Is displayed in the server, indicating that your JSP environment is successful! Since Tomcat itself has a web server, we don't have to install Apache, of course it can also be integrated with Apache, hereby. (2) Solution 2: J2SDK Apache Tomcat Although Tomcat can also make a web server, the speed of the static HTML is more than Apache, and its function as a web server is far less than Apache, so the Apache and Tomcat are integrated, and Apache acts as a web Server, while Tomcat is a dedicated JSP engine. The configuration of this solution is more complicated, but it enables Apache and Tomcat to integrate, and achieve powerful functions. Note that because the IIS web server uses the 80 port by default, the Apache's default port is also 80, so if you use the Win2000 operating system, and pre-installed IIS, for convenience, please stop the IIS service before doing the following. 1. Install the Apache running the downloaded apache_2.0.43-win32-x86-no_ssl.exe, install it to F: / Apache2 according to the wizard. (Note that after the installation of Apache2.0.43, the index.html.en under the F: / Apache2 / HTDOCS directory must be renamed to index.html so that the Apache's welcome interface will be displayed normally when testing the default service). 2. After the Apache default service is installed, the Apache server has run automatically.
Open the browser, type in the address bar: http: // localhost (Tomcat default port is 80), if you see the welcome interface of Apache in the browser, the Apache is working fine. 3. Install Tomcat as follows, and ensure that it runs normally. 4. Copy the downloaded mod_jk-2.0.42.dll to the F: / Apache2 / Modules directory. 5. Establish the work file required for the MOD_JK module work. Open the text editor, enter the following statement: workers.tomcat_home = f: / tomcat4 (let the mod_jk module know Tomcat) workers.java_home = f: /j2sdk1.4.1 (let the mod_jk module know JSDK) PS = / worker.list = ajp13 MOD_JK module version) worker.ajp13.port = 8009 (MOD_JK work port) worker.ajp13.host = localhost worker.ajp13.type = ajp13 worker.ajp13.lbFactor = 1
Save the above statement in the F: / Tomcat4 / Conf directory in workers.properties (Note: The extension of the file is .properties).
6. Configure Apache.
Open f: /apache2/conf/httpd.conf with text editor
1) Find "DirectoryIndex", add index.jsp after index.html.var;
2) At the end of httpd.conf, the following paragraph (explained in parentheses)
LoadModule JK_Module Modules / MOD_JK-2.0.42.dll
(Loading the MOD_JK module, used to handle the connection between Apache and Tomcat)
JKWorkersFile "f: /tomcat4/conf/Workers.properties"
(Pointing out the position of the work file worker.properties required for the MOD_JK module work)
JKMOUNT / Servlet / * ajp13
JKMount /*.jsp Ajp13
(Send all servlets and JSP requests to Tomcat through the AJP13 protocol, let Tomcat process)
3) Save after the addition is completed.
7, configure Tomcat
Use the text editor to open f: /tomcat4/conf/server.xml. Because Tomcat4 does not enable AJP13 by default, find out the following code:
->
Delete the comment symbol to enable AJP13.
Then save, now Tomcat and Apache's integrated configuration is basically completed.
8, overall test
Put Test.jsp in the F: / Tomcat / WebApps / Examples / JSP directory, start Apache2, Tomcat4 in turn. Open the browser, enter http: // localhost: 8080 / example in the address bar, if "Hello World!" Appears in the browser, then Tomcat is reconfigured, you will work normally; enter HTTP in the address bar : // localhost / examplep, if the result is the same as http: // localhost: 8080 / example / jsp /test.jsp, then the Apache and Tomcat are successful! (3) Solution 3: J2SDK IIS Tomcat
The most commonly used web server under the Windows platform is undoubtedly IIS. Under normal circumstances IIS do not support JSP, we can use an IIS to Tomcat to redirect plugins, allow IIS to send all JSP requests to Tomcat, allowing IIS to increase processing JSP function. If you are used to using IIS, you can try this configuration. (If you have already installed the Apache server, please uninstall Apache in order to make it easier.)
1. Install Tomcat as follows, and ensure that it runs normally. (For example, install to F: / Tomcat4);
2. Download the downloaded TC4NTIS.ZIP directly into the F: / Tomcat4 directory. Check the file required by the configuration, 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
3, open F: /Tomcat4/conf/ntiis/workers.properties with text editor, modify the following value:
Workers.tomcat_home = f: / tomcat4
Workers.java_home = f: /j2sdk1.4.1
4, double-click F: /Tomcat4/conf/ntiis/iis_redirect.reg, add the information within this registration file to the registry, but to modify the key value of the three keys of log_file, worker_file, worker_mount_file, to suit your environment (For example, Tomcat in this article is installed in F: / Tomcat4, not the default C: / Tomcat4). After adding and modified, you will be 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 launch the default site.
6. Right-click the server name in the Internet Service Manager, select the "WWW Service" → "ISAPI Filter" → "ISAPI Filter" → "ISAPI Filter" → "ISAPI Filter" tab, add an ISAPI filter, name is Jakarta Redirect, the executable is specified as f: /tomcat4/bin/native/isapi_redirector.dll. After adding the ISAPI filter, the status of Jakarta Redirect is a red downward arrow, restarting the IIS service, turning green arrow. 7, edit the server.xml file and save (step 7 of the same second).
8, restart IIS and Tomcat.
9. Test item: put the test.jsp in the F: / Tomcat / WebApps / Examples / JSP directory. Open the browser, type http: // localhost: 8080 / example in the address bar, if "Hello World!" Appears in the browser, then the Tomcat is reconfigured, and it works fine; enter HTTP in the address bar : // localhost / examplep, if the result is the same as http: // localhost: 8080 / example, the result is the same, that IIS and Tomcat are successful!
Five, conclude
The operational environment of building JSP is the foundation of learning JSP technology. There are many JSP engines, and there are many configuration methods, and the software version is constantly upgrading. You can choose the appropriate configuration method according to your needs and actual conditions. I hope that there are several JSP environmental configurations given in this article to help people who want to learn JSP.