Back to: JSP Tutorials for Beginners and Professionals
JSP Web Application Development using Eclipse IDE
Download Eclipse From https://www.eclipse.org/downloads/
JSP Web Application Development using Eclipse IDE:
In this, we will create a simple JSP file and run it on Eclipse IDE using Apache Tomcat Server. We need to follow these steps to create a servlet example:
Step-1: Create a Dynamic Web Project
Open Eclipse IDE and then Select File-> New -> Dynamic Web Project from the context menu as shown in the below image.
It will open the New Dynamic Web Project window and from this window, you need to give the Project name as HelloWorldJSP (you can give any name as per your choice) and then select the Target runtime and finally click on the Next button as shown in the below image.
Once you click on the Next button, it will open the following window where you just need to click on the Next button as shown below.
From the next window, check the “Generate web.xml deployment descriptor” checkbox and click on the “Finish” button as shown in the below image.
Once you click on the Finish button, the Eclipse IDE will generate the web project automatically with the following folder and file structure:
Step-2: Create JSP Page
Right-click on the “WebContent” folder and then select New -> JSP File from the context menu which will open the New JSP File window as shown in the below image.
From the New JSP File window, give the file name as “helloWorld.jsp” in the “File Name” field and then click on the “Finish” button as shown in the below image.
Once you click on the Finish button, Eclipse will generate a JSP Page and open the same in the JSP editor as shown below.
Step-3: Write JSP Code
Modify the “helloWorld.jsp” as shown below:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> </head> <body> <%="Hello World!"%> </body> </html>
Step-4: Run your JSP Code
Right-click on “helloWorld.jsp” and select Run As -> Run on Server option from the context menu as shown in the below image.
Select the existing Tomcat server. If not available then manually define a new web server as shown in the below image.
Once you click on the “Finish” button, the HelloWroldJSP web application will be deployed in the tomcat web server.
The eclipse will open a browser and your server-side JSP code will print “Hello world!” in the browser.
In the next article, I am going to show you the step-by-step process to create and run the JSP Web Application using the MyEclipse IDE. Here, in this article, I try to explain the step-by-step process to create and run the JSP Web Application using Eclipse IDE. I hope you enjoy this JSP using Eclipse IDE article.