Setting up Java Development Kit
First, download Java Software Development Kit (JDK) from Oracle’s Java site and setting up PATH environment variable appropriately.
Install and configure the JDK and set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.
On Unix (Solaris, Linux, etc.), if the SDK is installed in /usr/local/jdk1.8 and you use the C shell, you would put the following into your .cshrc file.
setenv PATH /usr/local/jdk1.8/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.8
Setting up Web Server: Tomcat
Apache Tomcat is an open source software implementation of the JavaServer Pages and Servlet technologies.
Download latest version of Tomcat from http://tomcat.apache.org/.
Unpack the binary distribution.
Tomcat can be started by executing the following commands on windows machine:
After a successful startup, the default web applications will be available by visiting http://localhost:8080/.
Tomcat can be stopped by executing the following commands on windows machine:
JSP Life Cycle
A JSP life cycle are listed as follows.
When a browser requests a JSP from the JSP engine, the JSP engine first checks to see whether it needs to compile the page.
If the page has never been compiled, or if the JSP has been modified since it was last compiled, the JSP engine compiles the page.
Suppose your Apache Tomcat is installed in C:\apache-tomcat.
Save the code below in JSP file hello.jsp and put this file in C:\apache-tomcat\webapps\ROOT directory and try to browse it by giving URL http://localhost:8080/hello.jsp in your browser address bar.