//// jsp Java Servlets Establishment and implementation of programming environment <1> /// / /// Win2000 Server Java 2 (JDK1.4.0) Apache1.3.23 Tomcat-4.0.3 WebApp-Module- 1.0 //// ////// //// author: josser chai (has now changed to Abner Tsai) //// address: abnertsai@sina.com or josserchai@yahoo.com //// 2002.3.7 ////:: // // I offer this file for only the use of learning, any individual and organization can be used. At the same time, if you find that there is a better, simpler method in the process of use, please ask for e-mail. Thank you! At the same time, please ask anyone when you turn the content of this document, please /// Keep this document statement. / // // / //////// / /// //// ///> in 2002.6.11, modify and add some content on this article, and the increased content is: /// How to set it yourself JSP and servlet directory and programs, and because there are many netizens to write to me, there is a mistake in the installation process ////, there is no implementation, because I work too busy, there are many netizens' believes, I haven't returned, please Forgive me. One / / / / must be done as much as possible. At the same time, the part of setting the ClassPath is set to make it more simple. // / / / / / / / / /: Note: There are various ways to configure JSP programming on the network, such as using Jserve Apache Tomcat, JSDK IIS, etc. But as a personal learning, I pushed Apache Tomcat. However, there are many ways to have many configurations on the network. Most of them are troublesome, such as using MOD_JK. And those methods are not applicable to the latest distribution software here (I tried, you can try, pay attention to the Windows series, if the Tomcat4.0 is combined, apache1.3.23 is the most stable version, Apache1 .3.6 or apache2.0 will have problems).
Java 2 (JDK1.4.0-B92) is the << Latest version >> Java compiler released by Sun. The download address is: www.sun.com/j2se/1.4/
Tomcat-4.0 is a web server that supports the latest JSP for Apache organizations. The download address is: http://jakarta.apache.org/builds/jakarta-tomcat/release/apache1.3.23-win32 is the Apache organization released the most stable web server that supports Window 98 / NT / 2000. The download address is: http://www.apache.org/dist/httpd/
WebApp-Module-1.0 is a support interface that Apache and Tomcat is better than Apache organization. The download address is: http://www.apache.org/dist/httpd/
Win2000 (Family) Server does not need to be explained. / / Oh, if you don't know, you don't look down.
Configuration method:
First, install Win2000, if you use it, this step can be.
Second, A: Download Java2 (JDK1.4.0), the downloaded file name is: J2SDK-1_4_0-win.exe. Double-click to run, press the default to install it to the C: /J2SDK1.4.0 directory. JRE will be automatically installed to C: / Program Files / Java / J2RE1.4.0, JRE is the necessary support environment that runs Java programs.
B: After installation, you need to set the path: The method is as follows: Click "My Computer" right-Property-Advanced - environment variable, the new "Java_Home" value in "System Variable" is: C: / J2SDK1. 4.0
Note: The row of the front belt // below is to choose one of the rows of //, that is, both only need to do one time. // New: ClassPath value is: //c:/j2sdk1.4.0 /LIB/dt.jar;c :/j2sdk1.4.0/lib/tools.jar;c:/j2sdk1.4.0/lib/htmlconverter.jar;c:/program files / apache tomcat 4.0 / common / lib / servlet.jar / / Note that you should write, use ";", " ; C: / program files / apache tomcat 4.0 / common / lib // Note To write, use ";" separation; // New: _Runjava, value is: c: /j2sdk1.4.0/bin/java // New: _Runjavaw, value: c: /j2sdk1.4.0/bin/javaw // New: _runjdb, value is: c: /j2sdk1.4.0/bin/jdb // The above variables built in compilation JSP and SERVLETS
Then, double-click the PATH variable here, add:; C: /J2SDK1.4.0/bin so that you can compile the Java file elsewhere.
C: Test JDK installation success: Built a Myjava directory in C: /J2SDK1.4.0, then copy C: /J2SDK1.4.0/Demo /Applets/clock to the case1.html to the Myjava directory, then Execute:> Javac Clock.java> AppletViewer Example1.html You can see a moving clock that pops up, indicating that the test applet is successful. Then Test the Java Application Use the following program to note the Note Test.java file, pay attention to the extension .java. Public class test {public static void main (string args []) {system.out.print ("Hello World, JDK SETUP SUCCESSFUL! / N");}} Put this Test.java file in the Myjava directory, then execute :> Javac Test.java> Java Test can see the "Hello World, JDK SETUP SUCCESSFUL!" Text, indicating that JDK is installed.
Third, A: Install Tomcat-4.0, downloaded the file name is: jakarta-tomcat-4.0.3.exe, run it directly and press it by its default directory to C: / Program Files / Apache Tomcat 4.0 below. B: Configure Tomcat Path: 1: Click "My Computer" right-Property - Advanced - environment variable, in "System Variable" New "Catalina_Home" value: c: / program files / apache tomcat 4.0 // 2 : Find the C: / Program files / apache tomcat 4.0 / bin / setclasspath.bat file, change all of these% basedir% // to% catalina_home% // and find the set classpath, change to: // set Classpath =% java_home% / lib / Tools.jar;% java_home% / lib / dt.jar;% java_home% / lib / htmlconverter.jar;% catalina_home% / common / lib / servlet.jar // setClassPath.bat file is Tomcat provides a batch file for setting library files, which can test whether your running environment // ClassPath is correct. Its content should be revised as follows: if not "% JAVA_HOME%" == "" goto gotJavaHomeecho The JAVA_HOME environment variable is not definedecho This environment variable is needed to run this programgoto end: gotJavaHomeif exist "% JAVA_HOME% / bin / java .exe "goto okJavaHomeecho The JAVA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programgoto end: okJavaHomeif not"% CATALINA_HOME% "==" "goto gotBasedirecho The CATALINA_HOME environment variable is not definedecho This environment variable is needed to run this programgoto end: gotBasedirif exist "% CATALINA_HOME% / bin / setclasspath.bat" goto okBasedirecho The CATALINA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programgoto end: okBasedirrem Set the default Java options for all scriptsset JAVA_OPTS = Rem set the default -djava.endorsed.dirs argumentset java_endorsed_dirs =% catalina_home% / bin;% catalina_home% / common / lib
rem Set standard CLASSPATHrem Note that there are no quotes as we do not want to introduce randomrem quotes into the CLASSPATHset CLASSPATH =% JAVA_HOME% / lib / tools.jar;% JAVA_HOME% / lib / dt.jar;% JAVA_HOME% / lib / htmlconverter.jar;% CATALINA_HOME% / common / lib / servlet.jarrem Set standard command for invoking Java.rem Note that NT requires a window name argument when using start.rem Also note the quoting as JAVA_HOME may contain spaces.set _RUNJAVA = " % Java_home% / bin / java "set _Runjavaw ="% java_home% / bin / javaw "set _runjdb =" java_home% / bin / jdb ": End // If you have a little understanding of the batch file, you can easily see Understand the code above.
Note: The top of the top with //, the row with the top of the top, select one, that is, the two can only be done once. C: Configure Tomcat configuration file, in C: / Program Files / Apache In Tomcat 4.0 / conf / server.xml, you are not configured, if you want to configure it, you can match it below. D: Test Tomcat Installation Success: Open IE, type in the address bar: http: // localhost: 8080 You can see Tomcat's page. Or enter http://xxx.xxx.xx.xxx:8080 where xxx.xxx.xx.xxx is your Win2000's IP address. E: How to configure Tomcat to run your own JSP file and Java servlet, will explain the following: 1: Configure the Tomcat's server.xml file to support your JSP file. Use Notepad to open the server.xml file below Conf, find it: ............! - Tomcat root context -> ->
<% = msg%> h2> body> html> saved file, boots Tomcat server, then in the browser Enter http: //xx.xxx.xxx.xx: 8080 / myjsp / helloWorld.jsp can see the output. Or enter http: //xxx.xxx.xxx.xx: 8080 / myJSP / you can browse the directory, then click the file. Note xxx.xxx.xxx.xx is your IP address, or LocalHost. Note: The file name is the case.
3: Sets the Tomcat to run your own servlet to build a class content in the web-inf directory below the root, then use Notepad to open the Web.xml of the web-inf directory in the ROOT in the
You can also use the
You can see a hello.class file in the class directory. If you have a problem with compilation here, check whether you set up the ClassPath and PATH. Then enter http: //xxx.xxx.xxx.xx: 8080 / hello.do to see the result of the servlet run in the browser. Where xxx.xxx.xx.xxx is your IP address. To this, you have configured your JSP and servlet running environment. Let's talk about how to join the Apache.
Fourth, A: Install Apache, go to download an Apache installation file, download the file name: apache_1.23-win32-x86-no_src.exe, run it directly and press the default directory to C: / Program Files / Apache Group / Apache below. Note: When installing this version of Apache, you will automatically find your servername, and automatically set the port number 80 and ask you to fill in the contact E-mail address of the Administrator, everything is default. B: Configure Apache, open the http.conf file under C: / Program files / apache group / apache / confed with Notepad, find: #Listen 3000 #Listen 12.34.56.78:80 two lines, remove the front ##, Change the above two rows to: listen 80 #Listen XXX.XXX.XX.XXX: 80 where xxx.xxx.xx.xxx is your IP address. Then find the port and confirm it after: 80; then find the servername and confirm that it is not your computer name as: worker16.soft.com (note that the name is clear, below To), where worker16 identifies the name of your computer, Soft.com is the domain name where your Win2K is located.
C: Here, your apache is just fine, test it: Enter: http://xxx.xxx.xx.xxx in IE See if there is an Apache default directory page.
V. Combine Apache and Tomcat with mod_webapp, allowing Apache to support JSP functions. A: Go to www.apache.org to download MOD_WEBAPP for Windows, the file downloaded is: WebApp-module-1.0-tc40-windows.zip. Unzip it into a directory such as TEST.
B: Copy libapr.dll in the TEST directory below below, Note that this directory is a directory for Apache installations. In this directory, there are also directorys such as lib, libexec, bin, logs, ie, libapr.dll, to place it in the root of Apache installation.
C: Copy the mod_webapp.so file in the TEST directory to C: / Program Files / Apache Group / Apache / Modules.
D: Use Notepad to open the C: / Program files / apache group / apache / conf / http.conf file, in the "last" plus the following lines: loadModule WebApp_Module Modules / Mod_Webapp.so WebAppConnection WarpConnection Warp localhost: 8008 WebAppDeploy Examples WarpConnection / Examples / EXAMPLES /
E: Open the C: / Program Files / Apache Tomcat 4.0 / conf / server.xml file with Notepad, find the following lines below:
So far, a system environment written in JSP is configured. Is it easy, everything else is installed by default, then a small change part, everything is done. If you use it for your personal learning, you can only install Tomcat, that is, the fourth and fifth steps are not performed.
7: Supplementary description: 1: When running your own servlet, if you change the .java source, you need to recompile, and you need to restart Tomcat and Apache. When needed, you also need to reset the web.xml file. When using Tomcat and Apache, you need to start Tomcat first, then start Apache. 2: When setting up Web.xml above, you can also pass parameters to the servlet, how to do it, please refer to Tomcat's instruction file. 3: When using: