Create a Simple JSP Page in Netbeans

Posted on

Based on the article written before which is titled ‘Introduction to HTTP Request’ in this link , this article will discuss on how to create a simple JSP Page using Netbeans to implement the actual HTTP Request generated from the client. Basically the requirement is specified below :

1. Java SDK installed and configured.

In order to have a slight grasp on how to do it, just read the article titled ‘How to Setup Java Environment for Netbeans in Ubuntu Linux operating system’ in this link.

2. Netbeans installed.

To see how to install Netbeans which is in the context of this article, it is demonstrated in Ubuntu Linux operating system, just read this article titled ‘How to Install Netbeans in Ubuntu Linux operating system’ in this link.

After all of the above requirement fullfilled, the process for creating a simple JSP Page in Netbeans can be started. Below are the steps executed by creating a Java Web Application project as shown below :

1. Run the Netbeans IDE.

The display of the Netbeans IDE execution can be shown as follows :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

Below is the display of Netbeans IDE after it has been successfully loaded :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

2. Create a new Java Web Application. Click File > New Project as shown below :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

Select Java Web and then Web Application as shown in the above image and then click button Next.

3. The following image will be presented after clicking the button Next above.

Just fill the project name into any name preferred. After inserting the project name and choosing the default project location, just click button Next to proceed.

4. This is the following image presented after clicking the Next button showing above :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

Click the Next button and the next window image will appear as follows :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

5. Below is the image of the IDE after creating the Java Web Application without having to add any frameworks at all :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

6.  After that, just right click at the project and create a new JSP file. Right click it at the Project name, it will then show the following menu :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

7. Specify the name of the newly created JSP file as shown below :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

8. For an example, just name the file name of the newly created JSP file is ‘index.jsp’. If the new file is successfully created, the following display of Netbeans will be presented :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

After the Finish button is clicked, the following is the content of the Project panel of Netbeans :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

9. Run the file by right click on the file name. After that click the Run File menu as shown below :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

10. The output will be presented in the browser where the actual JSP file is actually executed using the Glassfish Java Application Server specified upon creating the Java Web Application project. The following is the output of the executed JSP file :

Create a Simple JSP Page in Netbeans
Create a Simple JSP Page in Netbeans

The actual content of the newly created JSP file is shown as follows :

<%–
Document : index
Created on : May 19, 2018, 10:24:12 PM
Author : user
–%>

<%@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>Hello World!</h1>
</body>
</html>

 

So, based on the snippet code shown above, it is only printing a Hello World ! in the form of header 1 which is actually using a standard <h1></h1> HTML tag.



Leave a Reply