JSP Hello World Example

JSP Hello World Example


Posted in : Java Posted on : January 23, 2012 at 6:43 PM Comments : [ 0 ]

In this tutorial you will learn about how to create your first application in jsp.

JSP Hello World Example

In this tutorial you will learn about how to create your first application in jsp.

If you are new in jsp and don't know how to create an application in jsp not to worry here I am giving a simple example which will demonstrate you how to create your first application in jsp. For this I am going to give a "Hello World" example using the eclipse IDE. If you don't have the eclipse it need to be download first and remember when download the eclipse you have to download the "Eclipse IDE for Java EE Developers" (to download the eclipse click here ). To create a jsp application as a web content at first you would require a web server (to know about web server click here ) that should be properly installed and when you will use the IDE it should be configured within it. Here I will use Apache Tomcat server to deploy my example (to know how to configure Tomcat with eclipse click here ).

So lets start to create an example :

After doing all the preliminaries work start the eclipse and create a new Dynamic web project by selecting the File -> new -> Dynamic web project.

After clicking on Dynamic web project a window will be opened to you where you have to give your project name like "jspExample". Then click on "Finish" button.

After clicking on Finish button your project will be created as the name given by you.

Now you are ready to create a jsp. To create a jsp page right click on WebContent folder -> new -> JSP. You would be thinking that what the extension would be of this file, .jsp is the file extension of a jsp page (you can open a html page and write the contents as usual you are entering but when save it give the extension .jsp). It should be noted that your jsp page should be in the WebContent folder. The directory structure should be like as :

Example :

helloWorld.jsp

<%@ 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>Hello World Example</title>
</head>
<body>
<h2>A Hello World Example of JSP.</h2>
</body>
</html>

Output :

When you will execute this example you will get the output as :

Download Source Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics