In this tutorial, we will show you how to develop the first JSP page that outputs an important message: Hello World to the web browser.
If you do not have Java IDE available, we are highly recommended to install NetBeans IDE for practicing and learning JSP.
First, launch the NetBeans IDE.
Then, create new Web Application project by following the steps below:

From the File menu choose New Project… menu item

Choose Java Web > Web Application

Enter the name of the project: HelloWorld and Location where you want to store project file. We are using C:\JWeb

Choose the GlassFish Server so that you can execute the JSP. If you have Apache Tomcat installed, you can click Add.. button to use Apache Tomcat instead. We will use GlassFish server for the sake of simplicity.

We are not going to use any framework so just click finish to create HelloWorld project

NetBeans generates the project skeleton for you with a JSP page: index.jsp
Next, replace the code in the index.jsp file by the following code snippet:
1 2 3 4 5 6 7 8 9 10 11 | <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1><% out.println("Hello World!");%></h1> </body> </html> |
1 |

JSP – Run Project
The following screenshot is the output when you run the JSP page in the web browser. It displays the message “Hello World” as a standard heading H1 of the HTML page.

JSP – Hello World – Output
The index.jsp page is composed of HTML and Java code. The Java code is embedded inside the HTML document between notations <%
and %>
.
1 | <% out.println("Hello World!");%> |
println()
of the out
object to print the messasge "Hello World"
.Congratulation! you’ve developed the first JSP page and launch it in the web browser to get the output.