Often see the JSP novice ask Tomcat How to configure the JSP, servlet and bean issues, so summed up how to configure the JSP, Servlet and Ben, in the hope of helping those beginners.
Step one: Download J2sdk and tomcat: Download J2SDK to the Sun official site ([Url]http://java.sun.com/j2se/1.4.2/download.html[/url]), note that the download version is Windows Offline Installation SDK, it is also best to download j2se 1.4.2 documentation and then to the Tomcat official site ([url]http://www.apache.org/dist/jakarta/ Tomcat-4/[/url]) Download tomcat (Download the latest 4.1.x version of Tomcat);
Step Two: Install and configure your J2SDK and Tomcat: Perform J2SDK and tomcat setup, and then install it by default settings.
1. After installing J2SDK, you need to configure the environment variables to add the following environment variables in My Computer-> properties-> Advanced-> environment variable-> system variable (assuming your j2sdk is installed in c:\j2sdk1.4.2):
java_home=c:\j2sdk1.4.2
Classpath=.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar; (.;;; Must not be less because it represents the current path)
Path=%java_home%\bin
You can then write a simple Java program to test whether the J2SDK has been installed successfully:
public class Test{
public static void main(String args[]){
System.out.println("This is a test program.");
}
}
Save the above program as a file with a file name of Test.java.
Then open the Command Prompt window, the CD to your Test.java directory, and then type the following command
Javac Test.java
Java Test
At this point, if you see the print this are a test program, the installation is successful, if you do not print out this sentence, you need to carefully check your configuration.
2. After installing Tomcat, add the following environment variables in My Computer-> properties-> Advanced-> environment variable-> system variable (assuming your Tomcat is installed in C:\tomcat):
Catalina_home=c:\tomcat;
Catalina_base=c:\tomcat;
Then modify the classpath in the environment variable, add the Servlet.jar under the Tomat installation directory to classpath, and modify Classpath as follows:
Classpath=.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;%catalina_home%\common\lib\servlet.jar;
You can then start Tomcat and visit [Url]http://localhost:8080[/url] in IE, and if you see the Tomcat Welcome page, the installation is successful.