Js
Environment:
1, operating system: Windows 2000
This example uses the software to download the address:
1, jdk1.2.2
http://java.sun.com/products/jdk/1.2/
2, Jakarta-tomcat-4.1.exe
http://jakarta.apache.org/builds/tomcat/release/v4.0/
Installation method:
First, install the JDK
The first step is to configure the installation Jdk1.2.2-win.exe, the installation directory is D:\jdk1.2.2
The default installation directory for JRE is D:\Program FILES\JAVASOFT\JRE
Step two, update the environment variables
Start-> Setup-> Control Panel-> System-> Advanced-> Environment variable-> System variable
Variable
New Classpath:d:\jdk1.2.2\lib\tools.jar;d:\jdk1.2.2\lib\dt.jar
Add in Path: D:\jdk1.2.2;d:\jdk1.2.2\bin
After this step, if not configured incorrectly, your computer should be able to run the Java program correctly, now test, in the D-Packing directory to create a new text file, enter the following code:
public class hello{
public static void Main (String arg[]) {
System.out.print ("hi! Java! ");
}
}
This Java file's file name is Hello.java, note! Be sure to call Hello.java, and case-sensitive, do not ask why, later you will know, now do as I say to do the line. Next go to the MS-DOS mode in the D-Packing directory, enter the following instructions:
Javac Hello.java Carriage return
If normal, there is no content to display, but will be translated into a hello.class file under the same directory, then run the following instructions:
Java Hello Carriage
If it is normal, it will show "hi! java! " Characters on the screen, which means your Java environment is not a problem, you can do the next step.
Second, the installation of Tomcat
The first step is to extract the Jakarta-tomcat-4.1.exe into the D:\tomcat 4.1 directory
The second step is to enter the D:\tomcat 4.1\bin directory, locate the Setclasspath.bat batch file, and add the following two lines:
Start Set Tomcat_home=d:\tomcat 4.1
Set java_home=d:\jdk1.2.2
Step three, click Start Tombat to start the Tomcat server
At this point, a window named Catalina appears with some initialization information to prove that Tomcat is running successfully.
Step Fourth, enter http://localhost:8080 on the browser
If you can see the Tomcat Version 4.1 page, the Tomcat installation is successful. There are some examples of JSP and servlet, the JSP environment is completed.
Note: Windows Catalina cannot be turned off or the Tomcat server stops service
PS: How to make IT support the servlet:
Add D:\Tomcat 4.1\common\lib\servlet.jar in Classpath
Let's say we write a Congratulate.java
//--------------------------------------
Import needful Package
Import java.io.*;
Import javax.servlet.*;
Import javax.servlet.http.*;
Public class congratulate extends httpservlet{
public void doget (HttpServletRequest request,httpservletresponse response) throws Ioexception,servletexception
{
Response.setcontenttype ("text/html");
PrintWriter Out=response.getwriter ();
Out.println ("Out.println ("<body>");
Out.println ("hello!");
Out.println ("</body>"); Out.println ("Out.flush ();
}
}
//----------------------------------------
Javac Congratulate.java compiled into Congratulate.class
Put the compiled congratulate.class into the example directory web-inf\classes (my root does not have this directory, the new one put inside does not execute! Please contact me qq:78623269 advice!! )
Then open the http://127.0.0.1:8080/examples/servlet/congratulate to run it!
Success