Jsp Setup
# JSP Development Environment Setup
A JSP development environment is where you develop, test, and run JSP programs.
This section will guide you through setting up a JSP development environment, which involves the following steps.
If you are using the Eclipse environment, you can directly refer to: [Eclipse JSP/Servlet Environment Setup](#).
* * *
## Configure 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: (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
After downloading the Java JDK, please follow the given instructions to install and configure the JDK. Finally, set the PATH and JAVA_HOME environment variables to point to the directories containing `java` and `javac`, which are typically `java_install_dir/bin` and `java_install_dir`.
If you are using a Windows system and the JDK installation directory is `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_20bin;%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, and then conveniently set the PATH variable and confirm to exit.
On Linux/Unix systems, if the JDK installation directory is `/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 (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, you can try compiling and running a simple program to determine if the IDE already knows the JDK installation directory.
You can also refer to the tutorial in the (#) section of this site for this step.
* * *
## Set Up Web Server: Tomcat
Currently, there are many web servers on the market that support JSP and Servlets development. Some of them can be downloaded and used for free, and Tomcat is one of them.
Apache Tomcat is an open-source software that can run JSP and Servlets as a standalone server or be integrated into the Apache Web Server. Here is how to configure Tomcat:
* Download the latest version of Tomcat: [http://tomcat.apache.org/](http://tomcat.apache.org/).
* After downloading the installation file, unzip the archive to a convenient location, such as `C:apache-tomcat-5.5.29` on Windows or `/usr/local/apache-tomcat-5.5.29` on Linux/Unix, and then create the `CATALINA_HOME` environment variable pointing to these directories.
On a Windows machine, Tomcat can be started by executing the following command:
%CATALINA_HOME%binstartup.bat
or
C:apache-tomcat-5.5.29binstartup.bat
On a Linux/Unix machine, Tomcat can be started by executing the following command:
$CATALINA_HOME/bin/startup.sh
or
/usr/local/apache-tomcat-5.5.29/bin/startup.sh
After successfully starting Tomcat, you can use some of Tomcat's built-in web applications by visiting `http://localhost:8080/`. If everything goes well, you should see the following page:
!(#)
More information about configuring and running Tomcat can be found in the documentation provided by Tomcat, or by visiting the official Tomcat website: http://tomcat.apache.org.
On a Windows machine, Tomcat can be stopped by executing the following command:
%CATALINA_HOME%binshutdown.bat
or
C:apache-tomcat-5.5.29binshutdown.bat
On a Linux/Unix machine, Tomcat can be stopped by executing the following command:
$CATALINA_HOME/bin/shutdown.sh
or
/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh
* * *
## Set CLASSPATH Environment Variable
Since servlets are not part of Java SE, you must specify 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%commonlibjsp-api.jar;%CLASSPATH%
Alternatively, on Windows NT/2000/XP, you can right-click "My Computer", select Properties, then click Advanced, then click Environment Variables, and 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.
YouTip