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
I have tried putting a simple HelloWorld servlet in
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.
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:
and the web.xml is in the following folder
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"
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!
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:
'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).
I have a few more questions:
I have written servlets in packages, to separate out the logic.
I have four servlets in the following folders
The web.xml is as follows
Only the CodeBehind_Memberdetails.class is called from the jsp files.
Do I need to change all of the <url-pattern> elements so that they all follow the web.xml below?
Also using my previous web.xml, should I be able to call the servlet with
without any problem?
It seems that anything under the folder
works fine but if I put anything under the folder
I get the error 404 error with description The requested resource
(/jserv/servlet/com.golfclub.Controller) is not available.
Why does this happen?
Its my understanding of the web.xml that
tells tomcat where to find the servlet.
Does this then mean that tomcat is not finding the servlet? And if so would the host need to include any folders under
in the server.xml ias follows
this is a copy of the server.xml that the host is using.
Are far as I know the way I have set the folders up everything should work. Is there anything the host may have missed out when setting up tomcat?
They previously had tomcat 3 working but I couldn�t get any files to work at all, they upgraded to tomcat 4 which allowed the jsps to work inside the jserv folder, but only basic servlets in the classes folder
Having said that.. whatever way you choose to proceed, pick ONE and ALWAYS use that way. Either use the invoker servlet and call everything like /servlet/classNameHere or ALWAYS use an alias and never use /servlet.
*IF* your ISP has the invoker servlet enabled, then yes, you should be able to invoke your classes, with /servlet/classNameHere. In fact, if you go this route, you should probably leave your web.xml empty of servlet and servlet-mapping tags.
*IF* your ISP has disabled the invoker servlet, which they should, then serlvet/* should never work, unless you explicitly enable it, and you MUST provide servlet and servlet-mapping tags in appropriate pairings.
I think the answer to why the odd behaviour is happening is answered by your next question...
3) the servlet tag is 1/2 of how Tomcat finds servlets. YOU make a request of a certain url-pattern. So the servlet-mapping entries are the missing 1/2, and it's the 1st half as well. Your URL request is translated to a servlet-name, which is then translated to a servlet-class.
As for your ISP's file.. NO. I've never seen that before, and I think it's the cause of your trouble. A context's meaning is "web application". There is only one entry point to that application. Remove any entries with anything after /jserv (all the ones with /classes/etc/etc...)
4 ) See above. That server.xml file is *wrong*
[ March 26, 2003: Message edited by: Mike Curwen ]
I made the changes you suggested as follows.
I kept the web.xml as
and then called the servlet from the following url
and its still not working!
But now instead of getting an Apache/tomcat error screen, Im getting the standard HTTP 404 - File not found screen.
Im thinking that it may be that the ISP haven't set up their Apache/tomcat combination properly and the when a servlet is requested Apache does not know where to find it.
Is this a correct assumption?
I got the Host to check out things at there end and they have given me some feedback, as follows
I have had the response from next-level support. It seems that the
parameter HsMethod=1 is the one causing the 404
If you intentionally misspell the parameter say hsmethod=1, you get a
which means that apache does in fact forward the request to tomcat
I tried this and it does indeed give an error, as it should.
What I am thinking now is that the servlet can't find the jsp page that I try to redirect to from the servlet.
I am using the following code to redirect to the jsp
which I think is the older way to redirect servlets
Does this then mean that it is directory naming issue?
If the jsp page is in the directory
and the servlet which is redirecting to the page which uses the above code, is in the following directory
then the servlet is looking for the jsp page in the directory above the servlet directory which is
which is the wrong directory.
This would then cause a http 404 error as the file does not exist there.
if i was to use
would this redirect the servlet back up to the top level?
Seems it is my sloppy coding problem!