Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problems getting servlets to work on Tomcat 4

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problems getting servlets to work on my host server.
I am using apache/tomcat 3 as my development server and the host is using apache/tomcat 4.
They have setup tomcat to pick up servlets in the following folder
www.drumpellier.com/public_html/jserv
I have tried putting a simple HelloWorld servlet in
www.drumpellier.com/public_html/jserv/WEB-INF/classes/
folder which worked fine, but when I upload the my files to the server I cant get any servlets to work.
I am hitting a servlet called Controller from the following link.
www.drumpellier.com/jserv/servlet/com.golfclub.Controller?HsMethod=1

Which then produces the following error
************************************************
HTTP Status 404 - /jserv/servlet/com.golfclub.Controller
With the description as:
description The requested resource (/jserv/servlet/com.golfclub.Controller) is not available
************************************************
The servlet is in the following folder:
www.drumpellier.com/public_html/jserv/WEB-INF/classes/com/golfclub/Controller.class
and the web.xml is in the following folder
www.drumpellier.com/public_html/jserv/WEB-INF/web.xml
the web.xml referring to this servlet is as follows
************************************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">;
<web-app>
<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>com.golfclub.Controller</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/com.golfclub.Controller</url-pattern>
</servlet-mapping>
</web-app>
**************************************************
I just want to make sure that everything I have done is correct.
I think the host may not be picking up the com, golfclub, folders, but I�m not sure.
Would it be better to create a war file and put it in the classes folder?
Any help greatly appreciated as Im totally stuck!
Craig
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the whole point of mapping servlets (or at least one of the points)... is to provide a public alias to your servlet class, so that you don't reveal to your user the package and class name; they don't really need to know this information.

It is likely that your host has disabled the /servlet/* mapping, so you will probably have to use the alias anyways.

I'd make the following change...
And call it like:

www.drumpellier.com/jserv/foo?HsMethod=1

'foo' can be replaced by anything you want.

as for this: Would it be better to create a war file and put it in the classes folder

WAR files don't go in the classes folder. They go either in a known location like the webapps folder under Tomcat's root (and since you're hosted, you probably don't have access to this folder)... or the location of a particular web-app's WAR file can be specified in server.xml (again you're hosted, so you probably don't have access to this file).
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm also going to move this to Apache/Tomcat forum...

While servlet mappings are generic, the /servlet/* mapping is Tomcat-specific, and after all, your title has "Tomcat" in it.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic