Hello World JSP Example
Before deploying JSP on your environment, ensure that the JAVA_HOME
environment variable is set. Also, download Apache Tomcat from the Apache site and set the TOMCAT_HOME
environment variable. Make sure that the PATH
and CLASSPATH
environment variables are also set.
Steps to Create Your First Web Application
- Create a
HelloWorld
folder with the following structure: TheHelloWorld
root folder should have the following structure:
- Create a
first.jsp
file that prints the “Hello, World!” code to the console. Type the code into Notepad and save it asfirst.jsp
. Place this file in theHelloWorld
root folder of your web application.
Deploying the HelloWorld Web App to Tomcat
To deploy the web app to Tomcat, copy the
HelloWorld
app to the Tomcat installed directory, i.e.,webapps
, and start the Tomcat server. The start script is located underTOMCAT_HOME\bin\startTomcat.bat
for Windows.Accessing the JSP file: To run the
first.jsp
file, open a browser and navigate to the address:http://localhost:8080/first.jsp
. This will display the executed JSP file.
so you are ready with learning with your first JSP page creation.