To work on JSP and make dynamic pages, you will need an environment where you can develop and run web applications created using JSP. An environment is basically a set of all the software and tools needed to create dynamic web pages, test them, and ultimately run them as a virtual client-server manner. In this chapter, you will learn about creating and setting up the environment for getting started with JSP programming.
Java Development Kit (JDK) Setup
This is probably the first thing you must do to work under Java supported tools and technologies. The steps are as follows:
- Download the Java SDK (Software Development Toolkit) from https://www.oracle.com/technetwork/java/javase/downloads/index.html, the official Oracle Java site.
- After downloading the SDK, follow the instructions of the installation package.
- After the JDK installation, some folders will be created on your hard drive. These are - bin, demo, include, jre, lib, src.
- Once you installed Java on your machine, you have to set the PATH along with the JAVA_HOME environment variable that will point to a particular directory where Java (java_install_dir/bin) and javac (java_install_dir) are residing.
- Please refer to the Java installation tutorial to learn further environment setup steps.
In case you have installed or are using IDEs (Integrated Development Environment) like IntelliJ IDEA, Eclipse, Borland JBuilder, NetBeans, BlueJ, etc., then this software already knows where you have installed Java in your system.
To know more about Java installation and environment setup, please refer to our article in the Java section.
Setup and Install Apache Tomcat Server
Tomcat is a web server and not an application server. Tomcat is essentially a collection of several components as well as containers, which includes a Tomcat JSP engine, a range of different connectors, and servlet Container, but at its core resides the component that is termed as Catalina.
Steps to Download and Configure Tomcat:
- Tomcat is a free web server tool. You can download Tomcat from http://tomcat.apache.org/download-70.cgi.
- When you are done downloading the tomcat web server, unzip it in a particular location where you want. Let suppose you use the E drive to unzip Tomcat; then, your tomcat path will be E:\apache-tomcat-7.0.41. It is to be noted that by default, your Tomcat will get configured for running on port 8080, and hence, it can be accessed using http://localhost:8080.
- Now, you have to make a new environment variable with the name CATALINA_HOME, and you have to assign a value to the apache-tomcat installation directory. Let suppose E:\apache-tomcat-7.0.41
- To start and stop the Tomcat server, you have to use the batch files offered in %CATALINA_HOME%/bin
- startup.bat for starting your server.
- shutdown.bat for stopping your server.
- For more information regarding configuration and running Tomcat server can be read from here: https://tomcat.apache.org/