Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Servlet URL Mapping Evil!

Reply
Thread Tools

Servlet URL Mapping Evil!

 
 
Fran Cotton
Guest
Posts: n/a
 
      07-25-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: servlet annotations for URL mapping? Mike Schilling Java 3 05-02-2008 04:53 PM
how can I get the servlet access url from servlet context shaoanqing@gmail.com Java 4 04-20-2007 09:10 AM
problem: j2ee, web.xml, about set 2 servlet mapping to the same url sods Java 5 01-09-2006 09:40 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
problems with servlet-mapping url-pattern lbrtchx Albretch Java 2 07-11-2003 08:19 PM



Advertisments