May 14, 2021 Servlet
The development environment is where you can develop, test, and run servlets.
Like any other Java program, you need to compile the Servlet by using the Java compiler javac and, after compiling the Servlet application, deploy it in a configured environment for testing and running.
This development environment setting includes the following steps:
This step involves downloading the Java Software Development Kit (SDK, or Software Development Kit) and setting the PATH environment variables appropriately.
You can download the SDK: Java SE Downloads from Oracle's Java website.
Once you have downloaded the SDK, follow the given instructions to install and configure the settings. Finally, set path and JAVA_HOME environment variables to directories that contain java and javac, typically java_install_dir/bin and java_install_dir, java_install_dir.
If you're running Windows and you're installing the SDK in C:jdk1.5.0_20, you'll need to put the following lines in .bat C:?autoexec file:
set PATH=C:\jdk1.5.0_20\bin;%PATH%
set JAVA_HOME=C:\jdk1.5.0_20
Alternatively, in Windows NT/2000/XP, you can right-click My PC, select Properties, and then select Advanced, Environment Variable. Then, update the value of the PATH and press the OK button.
On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk1.5.0_20 and you are using a C shell, you need to put the following lines in your .cshrc file:
setenv PATH /usr/local/jdk1.5.0_20/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.5.0_20
Also, if you use an integrated development environment (IDE, or Integrated Development Environment), such as Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to make sure that the IDE knows the Java path you installed.
There are many Web servers on the market that support servlets. Some Web servers are free to download, and Tomcat is one of them.
Apache Tomcat is an open source software implementation of Java Servlet and Java Server Pages technology that can be used as a stand-alone server to test Servlet and can be integrated into apache web servers. Here are the steps to install Tomcat on your computer:
On Windows, you can start Tomcat by executing the following command:
%CATALINA_HOME%\bin\startup.bat
or
C:\apache-tomcat-5.5.29\bin\startup.bat
On Unix (Solaris, Linux, etc.), you can start Tomcat by executing the following command:
$CATALINA_HOME/bin/startup.sh
or
/usr/local/apache-tomcat-5.5.29/bin/startup.sh
Once Tomcat is started, you can access the default application in Tomcat http://localhost:8080/ the browser address bar. If all goes well, the following results are displayed:
Further information about configuring and running Tomcat can be found in the application installation documentation, or you can visit the Tomcat website: http://tomcat.apache.org.
On Windows, you can stop Tomcat by executing the following command:
C:\apache-tomcat-5.5.29\bin\shutdown
On Unix (Solaris, Linux, etc.), you can stop Tomcat by executing the following command:
/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh
Because servlets are not part of the Java Platform Standard, you must specify the path of the servlet class for the compiler.
If you're running Windows, you'll need to put the following .bat in your C: autoexec file:
set CATALINA=C:\apache-tomcat-5.5.29
set CLASSPATH=%CATALINA%\common\lib\servlet-api.jar;%CLASSPATH%
Alternatively, in Windows NT/2000/XP, you can right-click My PC, select Properties, and then select Advanced, Environment Variable. Then, update the value of CLASSPATH and press the OK button.
On Unix (Solaris, Linux, etc.), if you're using a C shell, you'll need to put the following lines in your .cshrc file:
setenv CATALINA=/usr/local/apache-tomcat-5.5.29
setenv CLASSPATH $CATALINA/common/lib/servlet-api.jar:$CLASSPATH
Note: If your development directories are C:\ServletDevel (on Windows) or /user/ServletDevel (on UNIX), you'll also need to add them in CLASSPATH in a similar way to the one above.