JSP Hello World Program Tutorial with Eclipse and Tomcat Server


Tutorial Requirement :
Eclipse J2EE IDE (I am using Eclipse Mars version)
JDK installed (I am using JDK 1.8 version)
Tomcat Server (I am using Tomcat 7.1 version)

1. Create a New Dynamic Web Project

- In Eclipse under Project Explorer Right Click -> New -> Dynamic Web Project.

- Enter Project name: HelloWorld

- Target Runtime: Apache Tomcat vX.X

- Click : Next -> Next

On Web Module Page Check "Generate web.xml deployment descriptor" -> Finish.

2. Creating JSP page :

- Right Click on Project Folder HelloWorld -> New -> JSP File.

- Change File Name : index.jsp

- Click Finish

- Add the below lines in bold to your index.jsp page

index.jsp
<%@page import="java.sql.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>JSP Hello World Program</title>
</head>
<body>
  <%= "<h1>JSP : Hello World!!</h1> <br/> Today's DateTime : " %>
  <%= new java.util.Date() %>
</body>
</html>
3. Creating Tomcat Server:

- Menu : Window -> Show View -> Servers

- Right Click in Servers tab: New -> Server

- Select the Tomcat Version that you have installed on your system.

- Click on link Add and link to the Tomcat installed location.

4. Running JSP HelloWolrd Project :

Right Click on HelloWolrd Project -> Run As -> Run on Server

Run on Server: Click Next -> Finish.

Output :
Output JSP Hello World Program using Eclipse Tomcat Server.png
Output JSP Hello World Program using Eclipse Tomcat Server
Advertisements
Try Out Code2care Dev Tools:

Advertisements



Android Java Linux Microsoft Google Python macOS Notepad++ Microsoft Teams CSS PHP SharePoint Html Linux C Programs Bootstrap jQuery Sublime Android Studio Facebook Eclipse WhatsApp News MySQL Json HowTos JavaScript FTP S3


Advertisements


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR - https://donate.unhcr.org/in/en-in/ukraine-emergency