JSP – Hello World Tutorial

In this tutorial, we provide a step-by-step guide for creating a hello world web application using JSP technology.


  • Eclipse IDE (Mars release)
  • Java 1.7
  • Apache tomcat 7

1. Create dynamic web project

Open eclipse, then select File -> New -> Dynamic Web Project.

Web Project

In the next screen, fill the mandatory fields as above, you are free to choose any servlet version you want. In case you didn’t previously link apache tomcat to eclipse, then just click on “New Runtime” button and link your tomcat, in this tutorial i use Apache tomcat 7.

Click “Next”.
Web Project

Click “Next”.

Web Project

in the final screen, make sure to check ‘Generate web.xml deployment descriptor’ checkbox, so that eclipse generates automatically the web.xml file under WEB-INF.

Here we go, the structure of the generated project looks like the following:

Hello World JSP

2. Create Hello World JSP file

JSP files should be created under WebContent. 

In order to organize our JSP pages, we create a new folder called ‘pages’ under WebContent so that we store all the JSP pages of the application in one place.

The new structure of the project looks like the following:

Hello World JSP

Right click on the pages folder, then select New -> Other

JSP File

Search for ‘JSP File’, then click ‘Next’ .

In the next screen, name your file as ‘helloWorld.jsp’ and click ‘Finish’.

Now that eclipse generates a template JSP file under pages. Open the file in eclipse and modify it in order to print ‘Hello World’ message:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP - Hello World Tutorial - Programmer Gate</title>
<%= "Hello World!" %>

P.S: In web applications, dynamic and static files are automatically accessed by their full path relative to WebContent without the need to define them under web.xml.

e.g. In our example, we can access helloWorld.jsp using the following url:


In order to access our jsp file without the pages prefix, we should add ‘pages’ folder under ‘Deployment Assembly’ configuration as the following:

Right click the project then select ‘Properties’:

Deployment Assembly

In the next screen, select ‘Deployment Assembly’ tab, then add ‘pages’ folder through the ‘Add’ button.

Deployment Assembly

Now, you would be able to access helloWorld.jsp using the following url:


3. Deploy the applicaton

Follow this guide in order to setup Tomcat 7 in eclipse.

Then deploy your application to Tomcat 7, just drag and drop the application to the tomcat instance under servers view.

Deploy JSP to Tomcat

Now that the application is deployed successfully under Tomcat 7, in order to start tomcat, right click on tomcat instance -> Start.

4. Access the application

After starting up tomcat, you can access the helloWorld.jsp using the following url:


In order to find the port number of the application, double click on the tomcat instance in servers view:

Eclipse Tomcat Port

These port attributes are editable and you can change them anytime.

/HelloWorld-JSP: denotes the deployed application name.

Hello World JSP

/helloWorld.jsp: denotes the name of the requested JSP page.

Finally, the output of the url would look like:

Hello World JSP


3.7 3 votes
Article Rating

Hussein Terek

Owner of programmergate.com, I have a passion for software engineering and everything related to Java environment.

Newest Most Voted
Inline Feedbacks
View all comments
Mg Pyae Phyo Swe
Mg Pyae Phyo Swe
1 year ago

Nice Explaination

1 year ago

Thanks for this. It’s very simple but just what I needed.

1 year ago

Hi. Thanks for your explanation but I don’t like so much your way to indicate the “welcome page”, because I should specify it on the browser. I was looking for and I found a way that could be better that is making a web.xml file and inside it specify the welcome page as the following:


So now you don’t even need to write the name of the .jsp file in the brower.

1 year ago

Good example and tutorial. I develop on Windows but deploy to Linux. How do I deploy the JSP to Tomcat running on RedHat Linux?