Back to: JSP Tutorials for Beginners and Professionals
JSP Environment Setup
In this article, I am going to discuss the JSP Environment Setup. Please read our previous article where we gave a brief introduction to JSP. As part of this article, we are going to discuss the following pointers in detail.
- Setting up the Java Development Kit
- Setting up Web Server: Tomcat
- Setting up CLASSPATH
JSP Environment Setup
A development environment is where we can develop our JSP programs, test them, and eventually run them. Following are the steps to set up your JSP development environment which involves the following steps:
Setting up the Java Development Kit
Step1: It involves downloading an implementation of the Java Software Development Kit (SDK) and fixing the environment variable. You can download SDK from Oracle’s Java site by visiting the below URL:
Step2: You download your Java implementation, follow the given instructions to put in, and configure the setup. Finally set the JAVA_HOME environment variables to ask the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.
If you’re running Windows and install the SDK in C:\jdk1.8.0_181, you would like to feature the subsequent line in your C:\autoexec.bat file.
set PATH = C:\jdk1.8.0_181\bin;%PATH%
set JAVA_HOME = C:\jdk1.8.0_181
Alternatively, if you are using an Integrated Development Environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to verify that the IDE knows where you installed Java.
Setting up Web Server: Tomcat
A number of Web Servers that support JavaServer Pages and Servlets development are available within the market. Some web servers are often downloaded for free of charge and Tomcat is one among them.
Apache Tomcat is an open-source software implementation of the JavaServer Pages and Servlet technologies. It should act as a standalone server for testing JSP and Servlets. It should be integrated with the Apache Web Server. Here are the steps to line up Tomcat on your machine −
- Download the latest version of Tomcat from https://tomcat.apache.org/
- After downloading, unpack the binary distribution into a convenient location. For example, in C:\apache-tomcat-9.0 on windows
- After unpacking pointing to the same location create CATALINE_HOME environment variables.
Start Tomcat Server
Tomcat is often started by executing the subsequent commands on the Windows machine:
After a successful startup, the default web applications included with Tomcat are available by visiting http://localhost:8080/
Tomcat is often stopped by executing the subsequent commands on the Windows machine:
Setting up CLASSPATH
Since servlets are not a part of the Java Platform, you need to identify the servlet classes to the compiler.
If you’re running Windows, you would like to place the subsequent lines in your C:\autoexec.bat file.
set CATALINA = C:\apache-tomcat-9.0
set CLASSPATH = %CATALINA%\common\lib\jsp-api.jar;%CLASSPATH%
In the next article, I am going to discuss Working with IDE. Here, in this article, I try to explain the JSP Environment Setup. I hope you enjoy this JSP Environment Setup article.