Netbeans Tomcat Server

Back to: JSP Tutorials for Beginners and Professionals

Apache NetBeans provides editors, wizards, and templates to help you create applications in Java, PHP and many other languages. Cross Platform Apache NetBeans can be installed on all operating systems that support Java, i.e, Windows, Linux, Mac OSX and BSD. How to install Apache Tomcat 8.0 onto Netbeans 8.0.2Music: Drift2, 5CentsBack & KeepItReal by

JSP Web Application Development using NetBeans IDE

In this article, I am going to show you the step-by-step process to create and run the JSP Web Application using the NetBeans IDE. Please read our previous article where discussed JSP Web Application Development using the MyEclipse IDE. NetBeans IDE lets you quickly and easily develop Java desktop, mobile, and web applications, as well as HTML5 applications with HTML, JavaScript, and CSS. The IDE also provides a great set of tools for PHP and C/C++ developers.

Download NetBeans IDE from

JSP Web Application Development using NetBeans IDE:

In this, we will create a simple JSP file and run it on NetBeans IDE using Apache Tomcat Server. Follow the below steps to create the servlet in the NetBeans IDE:

Step-1:Create New Project

Open NetBeans IDE and then select File -> New Project option from the context menu as shown in the below image.

It will open the New Project window. From this window, select Java web -> Web Application and then click on the Next button as shown in the below image.

Once you click on the Next button, a new window is generated with a default project name. Now change the project name to “HelloWorldJSP” and select the location where you want to create the project and then click on the “Next” button as shown in the below image.

Once you click on the Next button, 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. And then click on the “Next” button as shown in the below image.

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 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. Note that you need to provide the path up to the bin directory of Tomcat Server.

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.html file in Web Pages under HelloWorldJSP.

Netbeans Stop Tomcat Server

Step-2: Creating JSP Page

In order to create a JSP Page, right-click on your project, and then select New -> JSP option as shown in the below image.

It will open the New JSP window. Here, give the File Name as “HelloWorld” and then click on the “Finish” button as shown below.

Once you click on the “Finish” button a JSP page will create automatically where edit the following code and save it (Ctrl+S).

For changing the port number for your server, go to service right click on Apache Tomcat -> Properties

Change the port number and click on the “close” button as shown in the below image.

Step-3: Run your Project

For running your project right-click on the project and select “Run” as follows.

The following output is generated through the specified JSP file.

Netbeans Tomcat View Server Output Disabled

In the next article, I am going to discuss the JSP API. Here, in this article, I try to explain the step-by-step process to create and run the JSP Web Application using NetBeans IDE. I hope you enjoy this JSP using NetBeans IDE article.

Download Netbeans

Download Netbeans to your local computer. Be sure to download aversion of Netbeans that includes Tomcat. The labs are still using NetBeans 8.2, so thatis the one I recommend that you download to your computer. NetBeans is transitioning from Oracle to Apache. For now, we will stay with the last, stable, Oracle release.

If you have already installed Netbeans and did not install the Web version or thefull version, then download either of those versions and reinstall. Netbeans will upgrade your current installation.

Editing tomcat-users.xml

All web applications that are deployed to my Tomcat server on ocelot mustuse the secure web.xml file, which only allows access to your web applicationsto you and me. In order to make it easy to develop locally and deploy remotely,it is necessary to set up your local Tomcat server that Netbeans is using, so that italso restricts access to your web applications.

Netbeans Tomcat Server.xml


Before you can edit the tomcat-users file, you must run a web application in NetBeans. Once a web application is run, then Tomcat will create many files and folders, including the tomcat-users file.

Edit the tomcat-users.xml file. This is the file thatidentifies the users and their roles in Netbeans. Some roles arepredefined by Tomcat: manager and admin. These roles give access to the adminand manager applications. Other roles can be created and then used to restrictaccess to resources. Each user name is assigned various roles.

To edit the tomcat-users.xml file:

  1. Click Tools -> Servers
  2. Copy the path of the Catalina Base folder (not the Catalina Home folder) and close the dialog window.
  3. Click File -> Open File
  4. Paste the path to the Catalina Base folder in the File Name box and hit Enter.
  5. Change to the conf sub-folder.
  6. Open tomcat-users.xml

Netbeans Tomcat Server Log

You have a copy of tomcat-users.xml in your local directory. You have theability to edit this file to configure who has access to your web applications.

  1. After the last role in the file, add a role for your user name
    <role rolename='your-user-name' />
  2. After the last user in the file, add a user for your user name
    <user username='your-user-name'
    roles='your-user-name,manager,manager-script,manager-gui' />

Refer to this example of a tomcat-users file. Anything between an opening <!-- and --> is a comment.

  1. Do not remove the user entry for ide. It is the username that Netbeans uses to manage your web applications.
  2. Add the role before any user tags.
  3. Be sure all the tags are before the closing <tomcat-users> tag.

Restart tomcat after modifying the tomcat users file. Go to the Services tab, select Servers, Select Tomcat, right-click and choose restart.

Using the secure web.xml file

Netbeans Tomcat Server Location

Newer versions of NetBeans do not add a web.xml to the web application, automatically. To add a web.xml to your web app, select File -> New File -> Web -> Standard Deployment Descriptor (web.xml).

Netbeans Tomcat Server

The final step is to use the secure web.xml file for your web appilcation. When you run the application, it will force you to log in, using the tomcat passwordthat I sent to you. Once this is done, you will be able to deploy your webapplication to ocelot without having to change it.

Netbeans Tomcat Server Download

Don't forget to edit the secure web.xml file and change all occurences of your-user-namewith your PantherMail username.