Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Servlet URL Mapping Evil! (http://www.velocityreviews.com/forums/t124827-servlet-url-mapping-evil.html)

Fran Cotton 07-25-2003 03:41 PM

Servlet URL Mapping Evil!
 
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




All times are GMT. The time now is 04:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.