English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JSP Environment Setup

The JSP development environment is the place where you develop, test, and run JSP programs.

This section will guide you through setting up the JSP development environment, including the following steps.

If you are using the Eclipse environment, you can directly refer to:Eclipse JSP/Servlet Environment Setup.

Configure Java Development Tools (JDK)

This step involves downloading the Java JDK and configuring the PATH environment variable.

You can download JDK from Oracle's Java page:Java SE Downloads

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 indicate the path to the folder including java and javac, which is usually java_install_dir/bin and java_install_dir.

If you are using the Windows system and the JDK installation directory is C:\\jdk1.5.0_20, then 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

Or, in Windows NT/2000/Under XP, you can directly right-click the My Computer icon, select Properties, then Advanced, then Environment Variables, and then you can easily set the PATH variable and confirm to exit.

In Linux/Under Unix systems, if the installation directory of JDK is /usr/local/jdk1.5.0_2If you are using the C shell and 0, then 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 similar to Borland JBuilder, Eclipse, IntelliJ IDEA, and Sun ONE Studio, you can try to compile and run a simple program to determine whether the IDE (Integrated Development Environment) knows the JDK installation directory.

You can also refer to this site for this stepJava development environment configurationchapter tutorial.

Configure the web server: Tomcat

Currently, there are many web servers on the market that support the development of JSP and Servlets. 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, and can also be integrated into the Apache Web Server. The following is the configuration method for Tomcat:

  • Download the latest version of Tomcat:http://tomcat.apache.org/.

  • After downloading the installation files, unzip the compressed file to a convenient location, such as C:\apache under Windows.-tomcat-5.5.29 directory or Linux/under Unix /usr/local/apache-tomcat-5.5.29 directory, then create an environment variable CATALINA_HOME pointing to these directories.

On Windows machines, Tomcat can be started by executing the following command:

%CATALINA_HOME%\bin\startup.bat
or
C:\apache-tomcat-5.5.29\bin\startup.bat

In Linux/On Unix machines, 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 access it by visiting http://localhost:8080/ You can then use some of the web applications that come with Tomcat. 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 you can check the official Tomcat website at: http://tomcat.apache.org.

On Windows machines, Tomcat can be stopped by executing the following command:

%CATALINA_HOME%\bin\shutdown.bat
or
C:\apache-tomcat-5.5.29\bin\shutdown.bat

In Linux/On Unix machines, 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 the CLASSPATH environment variable

Since servlets are not part of Java SE, you must specify the compiler for 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%

Or, in Windows NT/2000/On XP, you just need to right-click 'My Computer', select Properties, then click Advanced, then click Environment Variables, and you can set the CLASSPATH variable and confirm to exit.

In Linux/On Unix machines, 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/If you are using Unix), then you need to add these paths to the CLASSPATH variable.