Download Netbeans

Download Netbeans to your local computer. Be sure to download a version of Netbeans that includes Tomcat. The labs are still using NetBeans 8.2, so that is 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 the full 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 must use the secure web.xml file, which only allows access to your web applications to 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 it also restricts access to your web applications.

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 that identifies the users and their roles in Netbeans. Some roles are predefined by Tomcat: manager and admin. These roles give access to the admin and manager applications. Other roles can be created and then used to restrict access 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

You have a copy of tomcat-users.xml in your local directory. You have the ability 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"
    password="your-tomcat-password"
    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

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).

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 password that I sent to you. Once this is done, you will be able to deploy your web application to ocelot without having to change it.

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