[plug] Java servlets with tomcat application server

Kirk Turner kirk.turner at wagoonline.com
Fri Jun 27 08:15:47 WST 2003


I'm guessing your just using one servlet, without a base jsp or html
file? If so, unless you have a servlet mapping in your web.xml, then
you'll need to put the whole URL:
http://localhost:8080/servlet/HelloClient

Or I'm not sure about the usage of .war files, it might be
http://localhost:8080/HelloClient/servlet/HelloClient

Just a note, I don't normally use a .war file, but put everything in a
subdirectory under the webapps directory, I find it easier for
development eg:
${CATALINA_HOME}/webapps/HelloClient/
And under there I would have the following directory structure
WEB-INF/web.xml
WEB-INF/lib 		- any jar files relevant to your servlets
WEB-INF/classes		- class files for the servlets

Under the ${CATALINA_HOME}/webapps/HelloClient/ directory you can also
put any static html files (ie an index.html) or .jsp files (thats what
the examples does - has a index.jsp file)

As to servlet mappings in your web.xml (under the WEB-INF file) you need
to add the following:

  <servlet-mapping>
    <servlet-name>helloclient</servlet-name>
    <url-pattern>/helloclient</url-pattern>
  </servlet-mapping>

Assuming there is the following defining the servlet:
  <servlet>
    <servlet-name>helloclient</servlet-name>
    <servlet-class>HelloClient</servlet-class>
  </servlet>

This would give you a URL to access it:
http://localhost:8080/HelloClient/helloclient


So a full web.xml would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
  <servlet>
    <servlet-name>helloclient</servlet-name>
    <servlet-class>HelloClient</servlet-class>
   </servlet>
   <servlet-mapping>
    <servlet-name>helloclient</servlet-name>
    <url-pattern>/helloclient</url-pattern>
  </servlet-mapping>
</web-app>


Hope that helps,

Kirk


On Thu, 2003-06-26 at 14:47, David Buddrige wrote:
> Hi all, 
> 
> I have written the attached [very] basic servlet.  I am now attempting to 
> run it using the TomCat application server.  I have placed the 
> HelloClient.war in the webapps/ directory of the jakarta-tomcat program, and 
> re-started the tomcat server by running the bin/shutdown.sh followed by the 
> bin/startup.sh scripts. However when I go to 
> http://localhost:8080/HelloClient, an error page is displayed rather than 
> the output of the HelloClient program. 
> 
> Do you know anything about how tomcat works, and why it might not be 
> working? 
> 
> thanks 
> 
> David. 
-- 
Kirk Turner <kirk.turner at wagoonline.com>
Software Engineer
WA Go Online Pty. Ltd.
Suite 5, 1 Sarich Way
Bentley WA 6102
Australia

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

mQGiBD6RSIgRBACRm7YZuE3hss6monmfVnGtOmDW2esXRp53AOiU0XAUnEQFtQCA
Iyhw+SwY5sbd94SzUTPveYOKRmLBSdaZqXrh5m1Kxe8f686bf6AKs1cvfOuzRPim
IozAso//ouq3G50PLWjIYTy7JYdz9MYCOG1K3loT3FhZh+2JO04+B71LgwCgzyP3
jWDynm7TrtUoY1XtDfAMkIED/in2XZqhuPU0zfwrpy3JGwk6Blj6+9RwwLCZI/ZV
kSQi37ftycNHxpFHtGdw9rTQqNuO3SHiuwIvtEa20m19QTOcd7OQV3zqAZDHNCim
07htCmVEzSSIVXcjEhLZl+wK5n474wgl9ASy+JnYj7vJEs6GehRTnwPF6pVTGzEX
Z0TpA/9NgzB9sRFDYr/D2fbcO2+0H1KX+x/kxoI2pfIQjt4c94EsQhX6F/5Q4FYA
iAVpcfR9/iSVOeldTT/Z5FlnRx8gIdDnT/dqccUXyahbFeZEr8pyCcj1sNb7Omox
iOoQuk2dK3qG+Qd4RfOpvpwyZoJOKN/QnyD1XSxNp76sSqImPbQ8S2lyayBUdXJu
ZXIgKFNvZnR3YXJlIEVuZ2luZWVyKSA8a2lyay50dXJuZXJAd2Fnb29ubGluZS5j
b20+iFcEExECABcFAj6RSIgFCwcKAwQDFQMCAxYCAQIXgAAKCRDAXmWE4BNAB0VB
AKCZQKI7pKW8aGshkYxIqcie+vILWQCfTyzCBiPPbnCqgdk8WfSZqlwp/LC5AQ0E
PpFIihAEALSMzB6GiCRh36bwg+/+o+N3RBlx2NhxNvRXiFVLNyeUsq19ZwK8sdX+
mrc/2e75Y5iakdOkIu5hQ5qEcp/OBm+RCP0kUgNmwSjydbYYNlgH/j2CNIaxPp1n
OxmtFaPfYN0eP67oUOpfSgViJh4HWgR7421WjPuZ0+lN0Weaoq8fAAMFA/4uJpt2
2AIqRYUAhLn4ag1X6uwwL8Y2zRMJKKE9mHz/nWqpL4QvMceVcGa3OKI6oR9sXONi
9szHpY1htVnieO3vXShVukmMW6eAK1KgnOXihTf++Z2CHgKBj9ueatOA7kxOYwsF
ZmVB4xo5ja3xxdfuj9Ec/GT18HgT17vOPYZGR4hGBBgRAgAGBQI+kUiKAAoJEMBe
ZYTgE0AHf7IAoKl67G9GT6RWJsjpOMeb89Sudb85AJ9Bl4nvDKTIVBYsczg5oZru
ORxHaA==
=XU88
-----END PGP PUBLIC KEY BLOCK-----


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.plug.org.au/pipermail/plug/attachments/20030627/222cee48/attachment.pgp>


More information about the plug mailing list