Deploying Web Applications to Tomcat
Pages: 1, 2, 3, 4, 5
To complete your deployment, copy the compiled tag library and the
taglib.tld into the
TOMCAT_ROOT/onjava/WEB-INF/lib directory.
To test you new tag library, you need to modify the welcome.jsp
page, replacing the Welcome message with a reference to the
<onjava:hello /> tag. You need to also add a taglib
directive referencing the taglib.tld to the
welcome.jsp file. The modified JSP is in Listing 7.
Listing 7 Modified welcome.jsp
<%@ taglib uri="/onjava" prefix="onjava" %>
<html>
<head>
<title>Onjava Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td>
<img src="/onjava/images/monitor2.gif"></td>
<td>
<b><onjava:hello /> : <%= request.getAttribute("USER") %></b>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
Now open the login.jsp page as described previously
and run through the demo again. This time instead of Welcome:
Bob, you should see the message Hello: Bob.
Creating and Deploying a WAR File
When your web application is ready for deployment, you need to
package it for distribution. As we discussed previously in Java Web Applications,
web applications are packaged in WAR files. The steps required to
"WAR-up" your /onjava web application and deploy it are
as follows:
Change to the root directory of your web application. In this case the root directory would be
TOMCAT_HOME/webapps/onjava/.Archive the web application:
jar cvf onjava.war .Copy the resulting WAR file,
onjava.war, to theTOMCAT_HOME/webappsdirectory.If you're deploying this WAR file to the Tomcat installation that you were developing in, then you will need to back up your development directory and remove it from the
TOMCAT_HOME/webappsdirectory.Add a new Context entry to the
/TOMCAT_HOME/conf/server.xmlfile, referencing the onjava web application.Restart Tomcat.
That's it. Your application should now be deployed and running. If
it isn't, check your entry in the
TOMCAT_HOME/conf/server.xml file to ensure that you have
set the appropriate values.
Now that you know how to create and deploy a web applications,
we'll examine the relationship of the web application and
its ServletContext in a future article.
James Goodwill is the co-Founder of Virtuas Solutions, LLC, a Colorado-based software consultancy.
Read more Using Tomcat columns.
Return to ONJava.com.



Good afternoon.
I need a help.
I am trying to install an open source DRM server in my system.
Here they are using Tomcat.
To access the DRM server we are using JBOSS Application server.After installation I am trying to acccess the server by
http://localhost:8080/openipmp/jsp/login.jsp.
But its giving error message
"
HTTP Status 404 - /openipmp/jsp/login.jsp
type Status report
message /openipmp/jsp/login.jsp
description The requested resource (/openipmp/jsp/login.jsp) is not available.
Apache Tomcat/5.5.9
"
If anyone is having any idea to resolve this problem, please share it.
Thanking you in advance..
with regards,
GK