Step by step approach for creating a JSP Application in Eclipse

This article explains the steps involved in creating simple Java Dynamic Web Application Project using Eclipse IDE and adding a simple JSP page with snapshot in it. Also with this we will able to understand about what Java Server Pages are and what are their role in a Java based Web Application.


Creating a JSP page is very simple. If you are new in JSP technology then you can go through The basics of JSP. You may also see Eclipse keyboard shortcut keys if you are not much familiar with Eclipse IDE. To write the first JSP page we need to configure Web Application Server with Eclipse. Here we will use Tomcat server and deploy our JSP single page application on Tomcat by using Eclipse.


Installation required

For creating JSP Web application, we need to download and install below components.
  • JRE
  • Tomcat
  • Eclipse IDE

JRE and Tomcat Server configuration in Eclipse

By configuring we tell Eclipse that where is the location of our Java Runtime Environment(JRE) and which Web Server to be used for running JSP application from within Eclipse. You may install and configure multiple number of Web Server. Based on your requirement you can choose the required one.
  1. JRE configuration: In Eclipse, go to Window > Preferences > Java > Installed JREs. In this section press Add provide JRE home directory and give some name for this JRE(Usually for Windows the path will be "C:\Program Files\Java\jre6..")
  2. Tomcat Server Configuration: In Eclipse, again go to Windows > Preferences > Server > Runtime Environments. Then press Add button for launching Add Server Wizard. Previously installed JRE will be set as default JRE Workbench.

Creating a JSP Web application in Eclipse

Create an empty Java Dynamic Web Project

First we will create a blank Dynamic Web Project using Eclipse and add our first "Hello World" JSP page in it. Then we will deploy it on Tomcat Web Server.
In Eclipse, go to File > Other, search for "Dynamic" > Dynamic Web Project. Select this and press next.


While pressing "Next" button we will go to the wizard. Here enter Project name and location to create this project. "Demo_JSP" in our case. Complete remaining wizard with default settings and press "Finish".


Change to 'Java' perspective set from default in Eclipse. Go to Window > Open Perspective > Other > Java, you can see the empty Web Application in 'Package Explorer' panel.



A deployment descriptor xml file is created in WEB-INF folder by Eclipse. It is used by Tomcat server. Soe default tag is already created in web.xml containing multiple entries for landing page for our application.


So when we create a new page with one of these names, and deploy our web project on tomcat, it will automatically know which page will be used as a home page.

Creaing a new JSP Page

To write our first JSP page, go to File > New > Other and enter 'JSP' and select 'JSP File'. Put a file name 'index.jsp' on the Wizard and select 'Demp_JSP' project. After that select 'New JSP File' html template. Once completed, a new index.jsp page will be created in WebContent folder. If no created go inside the folder.


Open index.jsp page and put below code snippet inside HTML body tags.
<%-- This is a JSP Comment before JSP Scriplet --%>
//It will show in Console
System.out.println("Hello World will display in Console!");

//It will show as a HTML page
out.println("Hello World!");
This above code contains a JSP comment, and a JSP Scriptlet. This code will print Hello World! in two different output streams. One is to Console and another one is to Response output stream.
You can find more info about JSP Technology specification on Oracle Website.

JSP Web Application deployment on Tomcat

Now its time to deploy and run the Web Project. Right click on 'Demo_JSP' project name in 'Package Explorer' panel within Eclipse.
From Project context select Run As > Run on Server. This will launch a new wizard 'Run on Server' and all our configured servers including Tomcat server will appears in the list, Select and click to Finish.


You check 'Always use the server when running this project to overcome unnecessary steps to follow.


When you click on Finish, it will start Tomcat server, and runs our application on it. Eclipse will automatically launch the application in it's internal browser. URL is, http://localhost:8080/Demo_JSP/
You can also copy paste this link to any other installed Web browser and they will show the same 'Hello World' output as well.


Related Articles

Career in Web developing-programming, website coordination and content development

A career in web developing is one of the most lucrative careers one can opt for after graduation. It holds a lot of promise with many web developers earning a hefty salary. With almost 80 million websites present over the internet and those numbers are ever increasing. This article contains an in depth analysis of a career in web developing,the courses to be taken up to become a good web developer and some of the places in India where we can study web developing.

How To Find A Successful Career In Web Developing?

In this article, I am explaining the different aspects of Web Developing. It explains what is a website and what is web developing. It outlines different careers in Web Developing like Content Developer, Web Coordinator, Web Developer, Webmaster, Graphic Designer etc. It also contains the courses and scope of remuneration in the field.

Some Basics Java Interview Questions

This is the list of JAVA FAQ's that are frequently asked in most of the interviews of an IT company.By going through these questions and answers not only you will qualify in the interviews but you will also have the overall basic knowledge of java.

Cake PHP - Development Framework For PHP

Here I describe the Rapid development framework used for PHP. By this article, you will be able to get more knowledge about the framework development in PHP. Here we clearly define the and principles used in cake PHP.

More articles: Web development Java basics Java Interview Questions Java


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: