Apache + Tomcat

xiaoxiao2021-03-06  39

Environmental configuration has always been a more annoying job! The purpose of this article is to easily set up and configure the execution environment of Servlet and JSP for you. First, go to java.apache.org to download a Tomcat3.1, Tomcat3.2. The author used Tomcat3.1. Download a zip file. Let it extract below a directory. For example, C: / below. A Jakatar-Tomcat directory will appear under the C drive. You can change this directory to your name. I change the name of the directory to Tomcat. Open the server.xml file in the C: / Tomcat / Conf directory now. Find ContextManager this tag, you will be able to see: Because Tomcat can be used as a separate server, there is its own PORT number. Here you can modify its default Port number. Note To modify the port number that has not been occupied on your machine. I changed to 9000. Now go to the C: / Tomcat / bin directory, you can see a batch file for startup.bat. Before executing this file, if you use JDK1.2.1 or JDK1.2.2, put the jdk_home / lib / Tools.jar this file in the classpath. (Note: To set ClassPath: Right-click "My Computer" à selection properties à environment, if there is no ClassPath, add one, if you have it, add JDK_HOME / LIB /Tools.jar) You can now execute the fileup.bat file. (If the prompt of Out of Environment Space is executed, the buffer size of your DOS window is larger. Specific method: attributes in the menu of the DOS window -> Memory -> Current and initial environment Improve the point) After the execution, Startup.bat will open Start Tomcat in another window. Now you can enjoy your results. Open the browser, in the address bar: http: // localhost: 9000 / then carries back. You should see a Jakatar-Tomcat. Now type in the address bar: http: // localhost: 9000 / examples / servlet /, Enter. You should see a servlet's INDEX page, click on the example servlet to see it. Type http: // localhost: 9000 / examples / jsp /, Enter. You should see a page similar to the servlet index page. Click on the JSP example to see it. If you have a 500 error after clicking a JSP, if there is no other error message, in the IE5 tool menu à Internet option à advanced, remove the option to the friendly HTTP error, then IE will report the specific Error information. The reason is that you didn't put Tools.jar in ClassPath. Now you have to connect Tomcat to Apache. First go to www.apache.org to download an Apache Web Server, I am using apache1.3.12.

Go to java.apache.org to download a JSERV, I use Jservev1.1.1. Install Apache Web Server first (such as below the C: / Apache directory). After installation, you need to modify the c: /apache/conf/httpd.conf file, find ServerName, modify the name you like, find the port, and modify the port that is not occupied. Install JSERV (for example, installed below the C: / Jserv directory). Install JSERV Need to specify the directory where JVM is located, you can specify the JDK_HOME / BIN directory. I need to specify the directory where JSDK is located, I specified is the directory after the JSDK installed from java.sun.com. (In fact, it is going to find servlet.jar file, you can specify Tomcat / lib / servlet.jar to try again, I didn't try this) this time actually Apache has supported servlet, but I don't support JSP . So you need to modify the c: /apache/conf/httpd.conf file. Use the text editor to open httpd.conf, in the final plus: include "Tomcat_home / conf / tomcat-apache.conf" (note that tomcat-apache.conf This file is automatically generated by Tomcat after Tomcat. So To open Tomcat first, open Apache. Now start Tomcat (c: /tomcat/bin/startup.bat), after another window appears, start apache (c: /apache/bin/apache.exe or by start menu à program à apache web serverà start apache start up). If you start Apache by the latter, there is a DOS window to flash after flash, indicating that there is a problem with the configuration of Apache Jserve Tomcat, and you should start Apache through the first method. You can on the screen. See the specific error message. If the error message is: Apj *: can't be specified more Than'. Once Per host. (* Represents some strings, such as APJSERVLOGLEVEL, etc.), you have to modify the C: /JSERV/CONF/JServ.conf file, you can remove the related line of the APJ *, you may need to note 5-6. If Apache is also started, now you can type http: // localhost: apache_port / example debug servlet in the address bar, here apache_port is the port number of Apache, can be modified C: / Apache / Conf / httpd.conf This file modifies the port number; Type http: // localhost: Apache_port / Examples / JSP / to debug JSP in the address bar. If the reader is careful, it will find that the previous test is an Examples / JSP directory. Tell you now how to create your own directory. Create a TestDir directory below in the C: / Tomcat / WebApps directory. Create a JSP directory and a classes directory under the TestDir directory. Now open the server.xml below the C: / Tomcat / Conf directory with a text editor.

转载请注明原文地址:https://www.9cbs.com/read-52885.html

New Post(0)