Deploying a Web Application


By default, a web application is deployed to the server you have specified when you run that project.

For applications that you deploy to the Tomcat server, the application is deployed in place, meaning that the IDE creates an XML file that is placed in the server's conf/Catalina/localhost/ directory and points Tomcat to the IDE project's build directory where the application files reside.

When you build a web project in the IDE, a WAR file is also created, which you can manually deploy to a server.

Customizing Contents of the WAR File

By default, a web project's generated WAR file includes

  • All files displayed within the project's Web Pages node, including the web.xml and context.xml files

  • Compiled class files of the source files within the Java Sources node, plus any other files placed there without the .java and .form file extensions

  • Any libraries that you have added to the project's Libraries node

You can also add JAR files to the WAR file and filter out contents that would normally appear.

To customize a WAR file's contents:

  1. Right-click the project's node in the Projects window and choose Properties.

  2. Select the Build | Packaging node.

  3. If you want to filter out contents from the generated WAR file, modify the regular expression in the Exclude from WAR File field.

  4. If you want to add folders or files, do so through the Add JAR/Folder, Add Library, or Add Project button.

    The Add JAR/Folder button enables you to add individual JAR files or folders, whether or not they come from IDE projects.

    The Add Library button enables you to add any JAR files or clusters of JAR files that you have designated in the IDE's Library Manager.

    The Add Project button enables you to add the JAR file that is output from another IDE project. When you add an IDE project to the WAR file, that project's JAR file is rebuilt every time you build the web application project.

Undeploying a Web Application

When you stop a web application that you have run through the IDE, the application remains deployed through a reference to that application in the form of an XML file in Tomcat's conf/Catalina/localhost directory.

To undeploy such an application from Tomcat:

  1. Open the Runtime window.

  2. Expand the Servers node; then expand the node for the Tomcat server and the server's Web Applications node.

  3. Right-click the node for the running web application and choose Undeploy.

Redeploying a Web Application

To remove your application from the server and then redeploy it, right-click the project's node and choose Redeploy Project.

Creating a WAR File

When you run the Build Project command on a web project in the IDE, a WAR file is created automatically and placed in the dist folder of the project. You can access this file and browse its contents in the Files window.

Deploying to a Different Tomcat Server

The IDE comes bundled with the Tomcat server, which facilitates web application development and testing. If you have a different Tomcat installation that you want to test on and/or deploy to, you can register that installation with the IDE. You can easily switch your application to work with the different server installations. This is particularly useful if you want to develop and test on one installation and then deploy to a production environment.

To set up the IDE to recognize a different Tomcat installation:

  1. Choose Tools | Server Manager.

  2. Click the Add Server button.

  3. On the Choose Server page of the wizard that opens, select a server from the Server combo box, enter an IDE display name for that server in the Name field, and click Next.

  4. On the Tomcat Server Instance Properties page, specify the Tomcat installation directory (and base directory, if it is a shared installation), and fill in an administrator username and password.

    You can also determine whether to enable the IDE's HTTP Monitor. If the HTTP Monitor is enabled, you can monitor your application's server requests, cookies, and so on, which makes it easier to debug your application. However, this option slows the server, so you will probably want this option disabled if you are using this server as your production server. See Monitoring HTTP Transactions later in this chapter for information on using the HTTP Monitor.

  5. Verify that the server is not using a port number used by another server. In the IDE, you can view the server's port number by mousing over the server's node and viewing the node's tooltip.

    If another server instance is using the same port, you need to stop one of the servers and change the port it is using. Stop the server by right-clicking the server's node and choosing Stop. Then right-click the server node, choose Properties, and change the Server Port property. Restart the server by right-clicking the node, choosing Start.

  6. If you have any existing web applications within the IDE that you want to run on the newly added server, modify the properties for each project to use the server. You can do so by right-clicking the project's node in the Projects window, choosing Properties, selecting the Run node, and choosing the server from the Server combo box.

If you later want to change the server's configuration, you can access the server's properties by opening the Runtime window, expanding the Servers node, right-clicking the specific server's node, and choosing Properties.




NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net