Configuration scheme of JSP running environment in Windows

Source: Internet
Author: User

Configuration scheme of JSP running environment in Windows <1>

 

Preparations before Configuration:

Software Name:J2sdk
Installation Package Name:J2sdk-1_4_2-windows-i586.exe
:Http://java.sun.com/
Software Name:Jakarta-Tomcat
Installation Package Name:Jakarta-tomcat-5.0.28.zip
:Http://jakarta.apache.org/
Apache-Tomcat

J2sdk installation and configuration:

1. My computer/properties/advanced/system environment variable/path
Add "E: \ j2sdk1.4.2 \ bin ;";

2. My computer/properties/advanced/system environment variable/java_home
Add "E: \ j2sdk1.4.2 ";

3. My computer/properties/advanced/system environment variable/classpath
Add "E: \ j2sdk1.4.2 \ Lib \ DT. jar; D: \ j2sdk142 \ Lib \ tools. jar; D: \ j2sdk142 \ Lib ;.;";
Pay attention to the next point. It indicates the current directory. After the directory is included, you can go to any directory and execute it. You need to use the JavaProgram;

4. Enter javac at the command prompt. If a parameter prompt is displayed, the installation is successful.

Tomcat installation and configuration:

1.decompress the jakarta-tomcat-5.0.28.zip file to the E: \ Tomcat directory.

2. My computer/properties/advanced/system environment variable/tomcat_home
Add "E: \ Tomcat ";

3. My computer/properties/advanced/system environment variable/catalina_home
Add "E: \ Tomcat ";

4. start Tomcat: Enter the "D: \ Tomcat \ jakarta-tomcat-5.0.5 \ bin \" Directory
Double-click STARTUP. BAT to start the Tomcat Service (double-click shutdown. BAT to close the Tomcat Service );

5. Enter http: // localhost: 8080 to display the welcome page for Tomcat;

6. Check the environment variable Configuration:
Write time. jsp in Notepad
<% @ Page contenttype = "text/html; charset = gb2312" %>
<% @ Page import = "Java. util. *" %>
<HTML>
<Body>
<P>
The current time is:
<% Date = new date ();
%>
<Br>
<% = Date %>
</Body>
</Html>

Store the time. jsp file in the directory e: \ Tomcat \ webapps \ Root, and enter http: // localhost: 8080/time. jsp.
Appears:
The current time is: XXXXXXXX (the current time on your computer)
Tomcat configuration is successful.

Solution to the default port conflict between Tomcat and Oracle9i:

The Oracle Servlet Engine page of oralce appears because the Oracle service input http: // localhost: 8080 is enabled first.

1. Modify Tomcat Port:

In E: \ Tomcat \ conf \ Server. XML, find:
......
<! -- Define a non-SSL coyote HTTP/1.1 Connector on port 8080 -->
<Connector Port = "8080" maxthreads = "150"
......
Change 8080 to another port, for example 5555.

2. Modify the port of oracle9i:

**************

How to create a virtual directory for Tomcat:

1. Under webapps:

1. Create a folder named test;

2. Create a WEB-INF folder under test;

3. Create the classes folder under WEB-INF;

4. My computer/properties/advanced/system environment variables/classpath plus "E: \ Tomcat \ webapps \ test \ Classes ;";

5. Restart tomcat;

6. Enter http: // localhost: 5555/test1/oracle. jsp (connect to Oracle ).

If you are connecting to sqlserver2000, you need the driver:

1. Create lib folder under WEB-INF;

2. Add msbase. jar, MSSQLServer. jar, and msutil. jar to LIB;

3. Restart tomcat;

4. Enter http: // localhost: 5555/test1/sqlserver. jsp.

2. Build in non-webapps:

* **************** (3) Open the "Tomcat 4.1" folder under drive C, then open the subdirectory "conf" and find "server. XML "file, open it in notepad and find"

Add this sentence before Code: <Context Path = "/zgtt" docbase = "D: \ zgtt" DEBUG = "0" reloadable = "true"

Crosscontext = "true"> </context>, and then save the file.

(4) Start the Tomcat server (see "4. Test Tomcat" for Instructions (1 ).

(5) After Entering the http: // localhost: 8080/zgtt/index. jsp link in IE, if you see "Hello world! The virtual directory zgtt is successfully set.

 

Configuration scheme of JSP running environment in Windows <2>

The JSP (Java Server Pages) introduced by Sun is a dynamic web page development technology executed on the server, which is based on Java technology. When executing JSP, you need to set up an engine for compiling JSP web pages on the web server. You can configure the JSP environment in multiple ways, but the main task is to install and configure the Web server and JSP Engine.
The following uses Tomcat as the JSP Engine and uses tomcat, Apache, and IIS as the three web servers to describe how to build a JSP running environment.

I. Introduction to related software

1. j2sdk: the software development tool of Java2, which is the basis of Java applications. 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 to provide web services.

3. Tomcat server: a JSP engine developed by Apache. It has the Web server function and can be used as an independent web server. However, as a Web server, Tomcat does not process static html pages as quickly as Apache, nor is Apache robust. Therefore, we generally use Tomcat with Apache, apache provides services for website static page requests, while tomcat, as a dedicated JSP Engine, provides JSP parsing for better performance. Tomcat itself is a sub-project of Apache, so Tomcat provides powerful support for Apache. Tomcat is a good choice for beginners.

4. mod_jk.dll: Developed by the Jakarta project team of Apache to support Tomcat plug-ins. With this plug-in, Tomcat can be seamlessly connected to Apache.

5. tc4ntiis.zip: Developed by the Jakarta project team of Apache to enable IIS to support Tomcat plug-ins.

2. Software Download

1. j2sdk

Version: j2sdk1.4.1 (35.9 MB)

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

2. apache2

Version: apache2.0.43 (6.69 MB)

Address: http://www.apache.inetcosmos.org/dist/httpd/binaries/win32/

3. tomcat4

Version: 4.1.21 (8.33 MB)

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/

5366tc4ntiis.zip (220kb)

Address: http://members.ozemail.com.au /~ Lampante/howto/tomcat/iisnt/tc4ntiis.zip

The above are free software.

3. Preparations before configuration

(1) Prepare a JSP webpage for testing

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

<HTML>
<Head>
<Title> JSP test page </title>
</Head>
<Body>
<% Out. println ("</Body>
</Html>

(2) install j2sdk

In either case, you must install j2sdk before installing and configuring the JSP Engine.

1. Install j2sdk

Run the j2sdk-00004_000001-windows-i586.exe file in windows and install it in a directory according to the installation wizard, for example, F: \ j2sdk 1.4.1;

2. Add Environment Variables

(1) If your operating system is WIN 98, you can use NotePad to directly edit autoexec. BAT 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 added environment variables will be valid.

(2) If your operating system is Win2000, do you have to roll around like a road? My computer, select "properties"> "system features"> "advanced"> "environment variables" in the pop-up menu. The environment variables dialog box is displayed, you can edit the environment variables of the system. Add three variables: path, java_home, and classpath. The variable value is the same as the preceding one.

Iv. jsp environment configuration Scheme

(1) solution 1: j2sdk + Tomcat

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

1. install Tomcat

Run the downloaded jakarta-tomcat-4.0.1.exe directly and install Tomcat according to the general installation steps of Windows programs. During installation, Tomcat is automatically located in j2sdk. For example, install it to F: \ tomcat4.

2. Configure Tomcat Environment Variables

Add a new environment variable tomcat_home with the variable value F: \ tomcat4. Add the same method as the j2sdk environment variable configuration method.

3. Test the default service

After setting, you can run the Tomcat server. Start Tomcat with F: \ tomcat4 \ bin \ startup.exe and disable Tomcat with F: \ tomcat4 \ bin \ shutdown.exe. (If an out of environment space error is prompted when startup.exeor shutdown.exe is executed, select "attribute" → "Memory" → "regular memory" in the menu of the DOS window ", change "initial environment" from "automatic" to "2816 .)

After starting tomcat, open the browser and enter http: // localhost: 8080 in the address bar. If you see the welcome interface of tomcat in the browser, indicates that Tomcat works normally.

4. Test Items

Run the test. place JSP in the F: \ Tomcat \ webapps \ examples \ JSP directory, and enter http: // localhost: 8080/examples/JSP/test in the address bar. JSP. If "Hello World!" is displayed in the browser! ", It indicates that your JSP environment has been configured successfully!

Because Tomcat itself has the functions of web servers, we do not need to install Apache. Of course, it can also be integrated with Apache. The following describes.

(2) solution 2: j2sdk + Apache + Tomcat

Although Tomcat can also be used as a Web server, its processing speed of static html is inferior to that of Apache, and its function as a web server is far inferior to that of Apache. Therefore, Apache and tomcat are integrated, use Apache as the Web server, while Tomcat as the dedicated JSP Engine. The configuration of this solution is complicated, but it can perfectly integrate Apache and tomcat to achieve powerful functions.

Note: Because the IIS web server uses port 80 by default, and the Apache default port is also port 80, if you are using the Win2000 operating system and preinstalled with IIS, for convenience, stop the IIS service before performing the following operations.

1. install Apache

Run the downloaded apache_2.0.43-win32-x86-no_ssl.exe file and install it to F: \ apache2. (Note: After apache2.0.43 is successfully installed, you must rename index.html.enas index.html under the F: \ apache2 \ htdocsdirectory to index.html, so that the welcome interface of Apache is displayed normally when the default service is tested ).

2. Test the default Apache service.

After installation, the Apache server runs automatically. Open your browser and enter http: // localhost in the address bar (Tomcat's default port is 80). If you see the welcome interface of Apache in your browser, Apache works properly.

3. Follow the steps in solution 1 to install Tomcat and ensure its normal operation.

4. Copy the downloaded mod_jk-2.0.42.dll to the F: \ apache2 \ modules directory.

5. work required to establish the mod_jk ModuleComposition.

Open the text editor and enter the following statements:

Workers. tomcat_home = F: \ tomcat4 (let the mod_jk module know about Tomcat)
Workers. java_home = F: \ j2sdk1.4.1 (let the mod_jk module know jsdk)
PS = \
Worker. List = ajp13 (module version of mod_jk)
Worker. ajp13.port = 8009 (working port of mod_jk)
Worker. ajp13.host = localhost
Worker. ajp13.type = ajp13
Worker. ajp13.lbfactor = 1

Save the preceding statement as the workers. properties file name in the F: \ tomcat4 \ conf directory (note: the file extension is. properties ).

6. Configure Apache.

Open F: \ apache2 \ conf \ httpd. conf in a text editor

1) locate "directoryindex" and add index. jsp after index.html. var;

2) Add the following code at the end of httpd. conf (which is explained in brackets)

Loadmodule jk_module modules/mod_jk-2.0.42.dll
(Load the mod_jk module to process connections between APACHE and tomcat)
Jkworkersfile "F:/tomcat4/CONF/workers. properties"
(Location of the workers. properties file required for mod_jk module work)
Jkmount/servlet/* ajp13
Jkmount/*. jsp ajp13
(Send all Servlet and JSP requests to Tomcat through the ajp13 protocol for Tomcat to process)

3) after adding the file, save it.

7. Configure Tomcat

Open F: \ tomcat4 \ conf \ Server. XML in 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 = "75" acceptcount = "10" DEBUG = "0"/>
-->

Annotate the symbol <! --> Delete to enable ajp13.

Save the configuration. Now the configuration of Tomcat and Apache is complete.

8. Overall Test

Place test. jsp in the F: \ Tomcat \ webapps \ examples \ JSP directory, and start apache2 and tomcat4 in sequence. Open your browser and enter http: // localhost: 8080/examples/JSP/test. jsp in the address bar. If "Hello world! ", Tomcat will work normally after reconfiguration. in the address bar, enter http: // localhost/examples/JSP/test. JSP. If it is different from http: // localhost: 8080/examples/JSP/test. if the JSP results are the same, it indicates that Apache and tomcat are successfully integrated!

(3) solution 3: j2sdk + IIS + Tomcat

The most common web server on Windows is undoubtedly IIS. Under normal circumstances, IIS does not support JSP. We can use an IIS-to-Tomcat redirection plug-in, enable IIS to send all JSP requests to Tomcat for execution, and enable IIS to process JSP requests. If you are used to IIS, try this configuration. (If you have installed the Apache server, uninstall Apache first to facilitate subsequent operations .)

1. Follow the steps in solution 1 to install Tomcat and ensure its normal operation. (For example, to F: \ tomcat4 );

2. decompress the downloaded tc4ntiis.zip file to the F: \ tomcat4 directory. View the files required for the configuration and 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 in 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, however, you need to 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, as shown in.

5. Open the Internet Service Manager and add a new virtual directory named Jakarta to the default site. The virtual directory points to F: \ tomcat4 \ bin \ native, and start the default site.

6. In Internet Service Manager, right-click the server name and select the "edit"> "ISAPI filter" tab of "properties"> "main attribute" www service, add an ISAPI filter named Jakarta redirect. the executable file is F: \ tomcat4 \ bin \ native \ isapi_redirector.dll. After the ISAPI filter is added, the Jakarta redirect status is a red downward arrow. After the IIS service is restarted, it becomes a green arrow.

7. Edit and save the server. xml file (same as step 2 of solution 2 ).

8. Restart IIS and tomcat.

9. Test Project: place test. jsp in the F: \ Tomcat \ webapps \ examples \ JSP directory. Open your browser and enter http: // localhost: 8080/examples/JSP/test. jsp in the address bar. If "Hello world! ", Tomcat will work normally after reconfiguration. in the address bar, enter http: // localhost/examples/JSP/test. JSP. If it is different from http: // localhost: 8080/examples/JSP/test. if the JSP results are the same, the integration of IIS and Tomcat is successful!

V. Conclusion

Building a JSP running environment is the basis for learning JSP technology. There are many types of JSP engines and many configuration methods, and the software version is constantly being upgraded, you can select an appropriate configuration method based on your needs and actual conditions. I hope the JSP environment configuration solutions provided in this article are helpful to those who want to learn JSP.

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.