The Tomcat Admin Webapp

Most of the work in this chapter has been figuring out what needs changing in a configuration file, knowing which XML to edit and then editing that file, and restarting either Tomcat or the affected web application. We end the chapter with a look at an alternative way of making changes to Tomcat's configuration—for some versions of Tomcat.

Tomcat versions before 6.0.0 (including 5.5.x and lower versions) included an administration webapp that allowed inspecting and modifying the configuration of Tomcat from a web application running within the same Tomcat instance. But, when the Tomcat developers refactored Tomcat for the 6.0 branch, they did not maintain the Admin webapp, so this webapp does not build or run on Tomcat 6.0.x, nor does the webapp come with Tomcat 6.0.x. If you want to run the Admin webapp, as of this writing, you must run Tomcat version 5.5.x or lower. The Tomcat developers are, however, planning to refactor and include the Admin webapp in the next branch of Tomcat after 6.0. It is possible that by the time you read this there will be a new branch of Tomcat that includes the Admin webapp.

Most commercial Java EE servers provide fully functional administrative interfaces; many of them are accessible as web applications. The Tomcat Admin webapp is a featureful Tomcat administration tool rivaling these commercial offerings. First included in Tomcat 4.1, it provides control over contexts, data sources, users, and groups. You can also control resources such as initialization parameters, as well as users, groups, and roles in a variety of user databases. The list of capabilities will be expanded upon in future releases, but the present implementation has proven itself useful.

To install the Admin webapp, you must download and unpack the Admin webapp's binary release archive over the top of Tomcat's CATALINA_HOME directory of Tomcat.

You must also configure a user who is assigned the admin role. There is no "default user," for security reasons. In CATALINA_HOME/conf/tomcat-users.xml, add a role with the name "admin", and make sure your user account's role memberships include "admin", like this:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="tomcat"/>
  <user username="role1" password="tomcat" roles="role1"/>
  <user username="both" password="tomcat" roles="tomcat,role1"/>
  <user username="
jasonb" password="
guessme" roles="admin"/>
</tomcat-users>

Once you've performed these steps and restarted Tomcat, visit the URL http://yourhost:8080/admin/html, and you should see a login screen. Once you have logged in as a user assigned the admin role, you will see a screen such as the one in Figure 2-1.

The Admin web application initial screen

Figure 2-1. The Admin web application initial screen

As you can see, the application provides for controlling the Tomcat Server, Host, and Context elements, accessing resources like JDBC DataSources, environment entries for web applications and user databases, and performing user administration tasks like editing users, groups and roles. You can make many kinds of changes to your Tomcat's configuration all through the use of this web interface.

Tip

Note that any changes you make will not take effect until you press the "Commit Changes" button before leaving the panel.

Figure 2-2 shows the Server Tree expanded.

Admin webapp—Server Tree expanded

Figure 2-2. Admin webapp—Server Tree expanded

Figure 2-3 shows one context selected and some of the actions one can perform on a context.

We'd like to close with the following points:

  • The Admin web application is a frontend for editing XML. You still need to know what you're doing when you fill in the forms, so the Admin webapp is no substitute for poor XML or the rest of this book.

  • When you commit your changes, all the comments and extra spacing that make the XML human-readable are discarded from your server.xml. The Admin webapp also specifically adds attributes with default values, adding a lot of verbosity to the XML configuration files. Consider this before you commit any changes.

  • Clicking on the wrong button can remove any part of your XML structure, so be careful (it does keep a backup of your server.xml file).

  • You (or the developers of relevant web applications) still need to edit the web.xml file within the webapp.

Admin webapp—actions on a context

Figure 2-3. Admin webapp—actions on a context

Having said all that, we encourage you to explore the Admin webapp and see whether it is in fact more useful than editing the XML directly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.119.114