Servlet URL Mapping Evil!

F

Fran Cotton

I was wondering if anyone could help? I've read the
docs and thought I understood what was going on!

Set-up: Tomcat 4.1 and JSDK 1.4.1 on Windows 2000

under the Tomcat webapps directory I have the
following structure set-up:

ServletAdventure
----------------WEB-INF
-----------------------web.xml
-----------------------classes
------------------------------test
----------------------------------HelloWorld.class

The HelloWorld servlet runs fine with the following URL:

http://localhost:8080/ServletAdventure/fred -- OK!

The web.xml file found below sets up the relationship
between fred and HelloWorld as expected. However, when
I try my truncated URL derived from the specified URL
pattern, it all blows up:

http://localhost:8080/john -- NOT OK!

< DELETED FOR BREVITY >

<web-app>
<servlet>
<servlet-name>fred</servlet-name>
<servlet-class>test.HelloWorld</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>fred</servlet-name>
<url-pattern>/john</url-pattern>
</servlet-mapping>
</web-app>

I thought the purpose of URL mapping was to allow
aliases to be setup to point at your servlet in a
short-hand form.

However, I get the following error:

javax.servlet.ServletException: Wrapper cannot find
servlet class HelloWorld or a class it depends on

I'm assuming that it cannot find the HelloWorld
class because it is looking relative to the webapps
directory for it as I'm no longer proving the app context
in the URL i.e. ServletAdventure.

Why it cannot find it I do not
understand as it works out that john maps onto
fred which in turn maps onto HelloWorld. If it can find
the appropriate web.xml file, why can it not as per
non url-patterned instances, find the class file relative
to web.xml?

AM I MISSING SOMETHING OBVIOUS HERE???!
Please help!

Should I be adding the classpath of url-patterned servlets
to some classpath or other? Please don't say the global one!
Have I not configured TomCat properly!?

Many thanks in advance,

Fran Cotton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top