How to Create JSP Web Page in Netbeans IDE 7.4 Using Tomcat Server 7.0.40

Introduction

In this article we discuss how to create a JSP web page in the Netbeans IDE 7.4 using the Tomcat Server 7.0.40.

To create a JSP web page in the Netbeans IDE we must do the following three main steps:

  1. Start by creating a "Java web" -> "web application project".
  2. Create a JSP web file.
  3. Last and finally, start the Tomcat Server and deploy the project.

Step 1: Start creating web application project

Step 1(a)

Open the Netbeans IDE to start your project.

fig-1.jpg

Step 1(b)

Now click on file menu and select New Project then select Java Web and then Web Application as follows.

From the file menu select "New Project" -> "Java Web" -> "Web Application" as in the following figure:

fig-2.jpg

Step 1(c)

Now click on "Next". A new window is generated with a default project name. Now change the name (I used "JspWebApplication") according to your project and click on "Next".

As in the following figure:

fig-3.jpg

Step 1(d)

Now a new window is generated for the server and setting the wizard. First go to the server and click on "Add server". Since I already set up the Tomcat Server, it is shown there but when you do it the first time it shows blank, see the image below.

fig-4.jpg

Step 1(e): Server and Setting wizard

First you need to configure Apache Tomcat Server 7.0.40

For configuration of the Tomcat Server follow my previous article from the following link:

 http://www.c-sharpcorner.com/UploadFile/fd0172/how-to-configure-and-install-apache-tomcat-server-in-windows/

After clicking on Add, a list of servers opens. In this article I used Tomcat Server 7.0.40. Choose your server and configure it. For Tomcat Server choose it (Apache Tomcat on screen) and click on "Next". Now a window opens asking for the server location. Now, click on the Browse button and find the server location where you have stored the Apache Tomcat Server (in my system it is in "E:\myserver\tomcat7.0.40\bin"). Note that you need to provide the path up to the bin directory of Tomcat Server. As in the following:

fig-5.jpg

Step 1(f)

After providing the server path you will see two more options for username and password. It's your choice whether you want your username and password or you want the default created by the Netbeans IDE. Now click on "Finish".

Now a window is generated containing the default index.jsp file in Web Pages under JspWebApplication. As in the following:

Fig-6.jpg

Step 2: Create a JSP Page.

Now change some coding in the default JSP page as given below.

index.jsp

Change the title: JSP Web Page

Change the heading: "Welcome To The JSP Web World!" as in the following:

Fig-7.jpg

Step 3: Run The Project using Tomcat Server.

Step 3(a)

First recheck the Tomcat configuration if you have changed the default port number of Apache Tomcat then you need to do the same in the Netbeans IDE.

For changing the port number of the Tomcat Server use the following.

Go to the services menu and then click on "Servers" and then right-click on "Apache Tomcat" and choose "Properties" as in the following:

Fig-8.jpg

Step 3(b)

Now select the server port number that you chose in configuring the Apache Tomcat Server. Since I chose port 9999 in Apache Tomcat so it needs to be changed in Netbeans also. As in the following:

Fig-9.jpg

Step 3(c)

Now click on close and run the project. For running your project right-click on the project and select "Run" as follows.

Fig-10.jpg

Output

The following output is generated through the specified JSP file.

Fig-11.jpg

Summary: This article describe how to create a JSP web page in the Netbeans IDE, hope you enjoyed doing it. If you encounter a problem creating a JSP web page or any issue occur then you can tell me.

Thanks for reading.

Up Next
    Ebook Download
    View all
    Learn
    View all