JSP Development Environment Setup
The JSP development environment is where you develop, test, and run JSP programs.
This section will guide you through setting up the JSP development environment, which includes the following steps.
If you are using the Eclipse environment, you can directly refer to:Eclipse JSP/Servlet Environment Setup。
Configuring the Java Development Kit (JDK)
This step involves downloading the Java JDK and configuring the PATH environment variable.
You can download the JDK from Oracle's Java page:Java SE Downloads
After downloading the Java JDK, follow the given instructions to install and configure the JDK. Finally, set the PATH and JAVA_HOME environment variables to point to the folders containing java and javac, typically java_install_dir/bin and java_install_dir.
If you are using Windows and the JDK is installed in C::\jdk1.5.0_20, you need to add the following two lines to the C:\autoexec.bat file:
set PATH=C:\jdk1.5.0_20\bin;%PATH%
set JAVA_HOME=C:\jdk1.5.0_20
Alternatively, on Windows NT/2000/XP, you can right-click the My Computer icon, select Properties, then Advanced, then Environment Variables; you can then conveniently set the PATH variable and confirm to exit.
On Linux/Unix systems, if the JDK is installed in /usr/local/jdk1.5.0_20 and you are using the C shell, you need to add the following two lines to the .cshrc file:
setenv PATH /usr/local/jdk1.5.0_20/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.5.0_20
Alternatively, if you are using an integrated development environment such as Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, you can try compiling and running a simple program to determine whether the IDE (integrated development environment) already knows the JDK installation directory.
For this step, you can also refer to this site'sJava Development Environment Configurationchapter tutorial.
Setting Up a Web Server: Tomcat
Currently, there are many web servers on the market that support JSP and servlet development. Some of them can be downloaded and used for free, and Tomcat is one of them.
Apache Tomcat is open-source software that can run JSP and servlets as a standalone server or be integrated into the Apache Web Server. The following is how to configure Tomcat:
- Download the latest version of Tomcat:http://tomcat.apache.org/。
- After downloading the installation file, extract the archive to a convenient location, such as the C:\apache-tomcat-5.5.29 directory on Windows or the /usr/local/apache-tomcat-5.5.29 directory on Linux/Unix, then create the CATALINA_HOME environment variable pointing to that directory.
On a Windows machine, Tomcat can be started by executing the following command:
%CATALINA_HOME%\bin\startup.bat
或者
C:\apache-tomcat-5.5.29\bin\startup.bat
On a Linux/Unix machine, Tomcat can be started by executing the following command:
$CATALINA_HOME/bin/startup.sh
或者
/usr/local/apache-tomcat-5.5.29/bin/startup.sh
After successfully starting Tomcat, you can use some of the web applications that come with Tomcat by visiting http://localhost:8080/. If everything goes well, you should be able to see the following page:

More information about configuring and running Tomcat can be found in the documentation provided by Tomcat, or on the Tomcat official website: http://tomcat.apache.org.
On a Windows machine, Tomcat can be stopped by executing the following command:
%CATALINA_HOME%\bin\shutdown.bat
或者
C:\apache-tomcat-5.5.29\bin\shutdown.bat
On a Linux/Unix machine, Tomcat can be stopped by executing the following command:
$CATALINA_HOME/bin/shutdown.sh
或者
/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh
Setting the CLASSPATH Environment Variable
Since servlets are not part of Java SE, you must indicate the compiler for the servlet classes.
If you are using a Windows machine, you need to add the following two lines to the C:\autoexec.bat file:
set CATALINA=C:\apache-tomcat-5.5.29
set CLASSPATH=%CATALINA%\common\lib\jsp-api.jar;%CLASSPATH%
Alternatively, on Windows NT/2000/XP, you just need to right-click My Computer, select Properties, then click Advanced, then click Environment Variables; you can then set the CLASSPATH variable and confirm to exit.
On a Linux/Unix machine, if you are using the C shell, you need to add the following two lines to the .cshrc file:
setenv CATALINA=/usr/local/apache-tomcat-5.5.29
setenv CLASSPATH $CATALINA/common/lib/jsp-api.jar:$CLASSPATH
Note: If your development path is C:\JSPDev (Windows) or /usr/JSPDev (Linux/Unix), you need to add these paths to the CLASSPATH variable.