The detailed steps in the application of JSP dynamic website environment

Source: Internet
Author: User
Tags iis web services win32 zip tomcat tomcat server

Sun's JSP (Java Server Pages) is a dynamic web development technology that executes on the server side, based on Java technology. When executing a JSP, you need to set up an engine that compiles JSP pages on the Web server. There are several ways to configure a JSP environment, but the main task is to install and configure the Web server and the JSP engine.

The following is the use of Tomcat as a JSP engine, with Tomcat, Apache, IIS three kinds of Web servers to tell the 3 kinds of building JSP operating environment scenarios.

Introduction of related Software

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: A common Web server developed by the Apache organization that provides Web services.

3, Tomcat server: Apache development of a JSP engine, itself has the function of a Web server, can be used as a stand-alone Web server. However, when Tomcat handles static HTML pages as a Web server, not as fast as Apache or as robust as Apache, we typically use Tomcat in conjunction with Apache so that Apache can service static page requests for the site, Tomcat, as a dedicated JSP engine, provides JSP parsing for better performance. And Tomcat itself is a subproject of Apache, so Tomcat provides strong support for Apache. For beginners, Tomcat is a good choice.

4, Mod_jk.dll:Apache organization Jakarta Project team developed to enable Apache support Tomcat Plug-ins. With this plugin, Tomcat is able to seamlessly connect to Apache.

5, Tc4ntiis.zip:Apache organization Jakarta Project team developed to enable IIS to support Tomcat Plug-ins.

Second, software download

1, J2SDK Learning Network. Com

Version: j2sdk1.4.1 (35.9MB)

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

Http://www.timefound.com.cn/info/data/resource/download/j2sdk-1_4_1_01-windows-i586.exe 20070108

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/

http://apache.seekmeup.com/tomcat/tomcat-5/v5.5.20/bin/apache-tomcat-5.5.20.exe20070108

http://tomcat.apache.org/download-55.cgi#5.5.20

4, Mod_jk.dll: (136KB)

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

5, Tc4ntiis.zip (220KB)

Address: Http://members.ozemail.com.au/~lampante/howto/tomcat/iisnt/tc4ntiis.zip

All of the above are free software.

III. Preparation before the configuration

(a) Prepare a test JSP page

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

The following are the referenced contents:

  

  

  

  

  

  

  

  

(ii) Installation of J2SDK

Regardless of the scenario, you must complete the installation of the J2SDK before installing and configuring the JSP engine.

1. Installation J2SDK

Under Windows, run the downloaded J2sdk-1_4_1_01-windows-i586.exe file directly, and install to a directory based on the installation wizard, such as installing to F:J2SDK 1.4.1;

2. Add Environment variables

(1) If your operating system is win 98, you can edit Autoexec.bat directly with Notepad, add the following command line:

The following are the referenced contents:

Path=%path%;f:j2sdk1.4.1bin

SET java_home=f:j2sdk1.4.1

SET Classpath=f:j2sdk1.4.1libtools.jar

After saving, restart the computer so that the environment variables you add are valid.

(2) If your operating system is Win2000, then right click "My Computer", in the pop-up menu select "Properties" → "system features" → "Advanced" → "Environment variables", Pop-up Environment Variables dialog box, you can edit the system environment variables. Add path, Java_home, and classpath three variables with the same value as above.

&nbs

P. Four, the configuration scheme of JSP environment

(i) Programme I: J2sdk+tomcat

In this scenario, Tomcat is used as both a JSP engine and a Web server, and is relatively simple to configure. *

1. Install Tomcat

Run the download directly jakarta-tomcat-4.0.1.exe, follow the usual Windows program installation steps to install the Tomcat, installed it will automatically find the location of the J2SDK. For example, install to F:TOMCAT4.

2. Configure Tomcat Environment variables

Add a new environment variable tomcat_home, the variable value is F:TOMCAT4, add method and J2SDK environment variable configuration method.

3. Test default Service

The Tomcat server can be run after Setup is complete. Start Tomcat with F:tomcat4binstartup.exe and close with F:tomcat4binshutdown.exe. (if prompted out of the environment space error when executing startup.exe or Shutdown.exe, select "Properties" → "Memory" → "normal memory" in the menu of the DOS window, and modify the "initial environment" from "automatic" to "2816" It's OK. )

After you start Tomcat, open the browser, enter http://localhost:8080 in the Address bar (the Tomcat default port is 8080), and if you see the Tomcat welcome interface in the browser, the Tomcat is working properly.

4. Test Project *

Put the test.jsp you just prepared in the f:tomcatwebappsexamplesjsp directory and enter http://localhost:8080/examples/jsp/test.jsp in the Address bar, if the browser displays " Hello world! ", it means that your JSP environment configuration success!"

Because Tomcat itself has the functionality of a Web server, we don't have to install Apache, but it can also be integrated with Apache, as described below. *

(ii) Programme II: J2SDK+APACHE+TOMCAT

Although Tomcat can also be used as a Web server, its handling of static HTML is not as fast as Apache, and its function as a Web server is far less than Apache, so integrate Apache and Tomcat, using Apache as a Web server, and Tomcat as a dedicated JSP engine. The configuration of this scenario is more complex, but it allows Apache and Tomcat to be perfectly integrated to achieve powerful functionality.

Note that because the IIS Web server uses port 80 by default, and Apache's default port is 80, if you are using the Win2000 operating system and the IIS is pre-installed, it is convenient to stop the IIS service before doing the following.

1. Install 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 is successful, you must rename the Index.html.en in the F:apache2htdocs directory to index.html so that the Apache welcome interface is displayed normally when you test the default service).

2. Test Apache default Service

After the installation, the Apache server has been automatically run. Open the browser and enter in the Address bar: http://localhost (the Tomcat default port is 80), and if you see the Apache welcome interface in your browser, Apache works fine.

3, follow the steps of the program to install Tomcat, and ensure that it runs normally.

4. Copy the downloaded Mod_jk-2.0.42.dll to the F:apache2modules directory.

5, the establishment of MOD_JK module work required working documents.

Open the Text editor and enter the following statement:

The following are the referenced contents:

WORKERS.TOMCAT_HOME=F:TOMCAT4 (Let the MOD_JK module know Tomcat)

workers.java_home=f:j2sdk1.4.1 (Let mod_jk module know JSDK)

ps=

WORKER.LIST=AJP13 (mod_jk version of the module)

worker.ajp13.port=8009 (mod_jk port of work)

Worker.ajp13.host=localhost

Worker.ajp13.type=ajp13

Worker.ajp13.lbfactor=1

Save the above statement in the f:tomcat4conf directory with the Workers.properties file name (Note: The file extension is. properties).

6, configure Apache. Open f:apache2confhttpd.conf with a text editor

1 Find "DirectoryIndex", add index.jsp after Index.html.var;

2 at the end of httpd.conf, add the following code (explained in parentheses) to learn the web. Com

The following are the referenced contents:

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.proper

Ties

(Indicates the location of the working file Workers.properties required for MOD_JK module work)

jkmount/servlet/* ajp13

Jkmount/*.jsp ajp13

(Send all servlet and JSP requests through the AJP13 protocol to Tomcat to be processed by Tomcat)

3) to save after the completion of the addition.

7. Configure Tomcat

Open F:tomcat4confserver.xml with a text editor. Because TOMCAT4 does not enable AJP13 by default, the following code is found:

The following are the referenced contents:

  

Delete the annotation symbol to enable AJP13.

Then save, now Tomcat and Apache's consolidated configuration is basically complete.

8. Overall Test

Put the test.jsp in the f:tomcatwebappsexamplesjsp directory and start the APACHE2,TOMCAT4 in turn. Open the browser, enter http://localhost:8080/examples/jsp/test.jsp in the address bar, and if "Hello world!" appears in the browser, the Tomcat is working properly; Enter http://in the address bar Localhost/examples/jsp/test.jsp, if the results are the same as the http://localhost:8080/examples/jsp/test.jsp, it shows that Apache and Tomcat are integrated successfully!

(iii) Programme III: J2sdk+iis+tomcat network. Com

The most common Web server under the Windows platform is undoubtedly IIS, and normally IIS does not support JSP, and we can enable IIS to send all JSP requests to Tomcat execution by using an IIS to the Tomcat redirection plug-in. You can make IIS more capable of processing jsps. If you are accustomed to using IIS, you can try this configuration. (If you have already installed the Apache server, please uninstall Apache for later operation.) )

1, follow the steps of the program to install Tomcat, and ensure that it runs normally. (e.g. installation to F:TOMCAT4); Learning Network. Com

2, will download the Tc4ntiis.zip directly to the F:TOMCAT4 directory. Review the files required by the configuration to ensure they are in the following locations:

F:tomcat4serverlibajp.jar

F:tomcat4serverlibtomcat-util.jar F:tomcat4binnativeisapi_redirect.dll f:tomcat4confntiisworkers.properties F: Tomcat4confntiisuriworkermap.properties F:tomcat4confntiisiis_redirect.reg

F:tomcat4logiis_redirect.log Network. Com

3. Open f:tomcat4confntiisworkers.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:tomcat4confntiisiis_redirect.reg to add the information in this registration file to the registry, but to modify the key values of the three keys, Log_file, Worker_file, and Worker_mount_file, to suit your environment (such as Tomcat in this article is installed in F:TOMCAT4 instead of the default C:TOMCAT4). Add and modify the following figure after completion.

5, open Internet Services Manager, add a new virtual directory on the default site, name Jakarta, this virtual directory points to F:tomcat4binnative, and start the default site.

6. Right-click the server name in Internet Services Manager, select Properties → the edit → ISAPI filter tab of the WWW service in the main property, add an ISAPI filter with the name Jakarta Redirect and the executable specified as F: Tomcat4binnativeisapi_redirector.dll. After adding an ISAPI filter, the state of the Jakarta redirect is a red downward arrow that restarts the IIS service and becomes a green arrow.

7. Edit the Server.xml file and save it (the 7th step of the same scheme II).

8, restart IIS and Tomcat.

9, test project: Put the test.jsp in the f:tomcatwebappsexamplesjsp directory. Open the browser, enter http://localhost:8080/examples/jsp/test.jsp in the address bar, and if "Hello world!" appears in the browser, the Tomcat is working properly; Enter http://in the address bar Localhost/examples/jsp/test.jsp, if the results are the same as those of http://localhost:8080/examples/jsp/test.jsp, it means that IIS and Tomcat consolidations are successful!

V. Concluding remarks

Build JSP operating environment is the basis of learning JSP technology, JSP engine a lot of types, configuration methods are also many, and the version of the software is constantly upgraded, we can according to their own needs and the actual situation to choose the appropriate configuration method. I hope this article gives some of the JSP environment Configuration scheme, for people who want to learn JSP help.

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.