JSP Hello World Example using Eclipse and Tomcat server
This simple tutorial describes how you can print "Hello World!" string in your browser by writing a simple JSP (Java server pages) program developed using eclipse IDE. After developing this example we will deploy this project on Tomcat Web Server.
Tools and Technologies used in this article :
- Eclipse Indigo
- Tomcat 6.0
- JDK 1.6
1. Create Dynamic Web Project
Open Eclipse IDE and create a new Dynamic Web Project by selecting File --> New --> Dynamic Web Project as shown bellow.
This simple tutorial describes how you can print "Hello World!" string in your browser by writing a simple JSP (Java server pages) program developed using eclipse IDE. After developing this example we will deploy this project on Tomcat Web Server.
Tools and Technologies used in this article :
- Eclipse Indigo
- Tomcat 6.0
- JDK 1.6
1. Create Dynamic Web Project
Open Eclipse IDE and create a new Dynamic Web Project by selecting File --> New --> Dynamic Web Project as shown bellow.
Provide the name of the project as HelloWorldJSP select Target runtime as Apache tomcatv6.0 and Dynamic web module version as 2.5 as shown bellow and click Next --> Next and Finish.
Directory structure of project is shown below
2. Create Jsp page
Right click on 'WebContent' folder and from menu select New --> Jsp File .
Write "index.jsp" in the 'File Name' field and Click "Finish" button as shown bellow.
Add following code into the file.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <%= "Hello World!" %> </body> </html>
6. Run It
Right click on 'index.jsp' and select from menu 'Run As' --> 'Run on Server'.
Browser Output
Eclipse will open a browser and your server side jsp code will print 'Hello World!' in the browser.
Related Articles