Display Hello World in JSP




Hey guys in this article, you will learn how to display Hello World in JSP web application with easy to understand steps.

Read More:

Overview


  • JSP is a HTML web page which contains some Java code in between
  • We can add Java code in between to display the dynamic content
  • JSP page is processed on the server
  • The JSP file should be place inside the WebContent folder
  • JSP page should have the extension .jsp
<p> The current date and time is <%= new Date(System.currentTimeMillis()) %> </p>

Create a Dynamic Project


To create a new dynamic project click on File, choose New, select Dynamic Web Project

00-01

Note: If you don’t find Dynamic Web Project then choose other and search for Dynamic Web Project, it will be present under the Web folder

00-02

Enter the Project name, Select the Dynamic web module version (At the time of writing this post, latest web module version is 4.0)

Create a JSP file


Create HelloWorld.jsp file under the WebContent folder and add the following content

<%@page import="java.util.Date"%>
<%@ 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>
	
	<h1>Hello World</h1>
	<p>Current date and time is <%= new Date(System.currentTimeMillis()) %> </p>
</body>
</html>

Run the file


Right click on the File, choose Run as, choose Run on Server, It will ask you to configure the server

00-06
Select Tomcat v9.0 under the Apache folder and Click on the add option to add the server

00-07
Provide the tomcat path and click Finish

Tip: Download the Apache tomcat from https://tomcat.apache.org/download-90.cgi

Once the tomcat is added to your workspace, Right click on the File, choose Run As, choose Run on Server.

00-03

It will open on the default web browser and you will see the following output
00-04

That’s it for this post, if you like this post, please share this post with your friends and collogues and also share this on your social media profiles.



Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply