You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Matt Goss <mg...@rtci.com> on 2000/11/03 21:56:34 UTC

servlet mappings???

Hi all,
I'm attempting to map a controller servlet so that any requests go
through it... (the MVC method).
I have a context/application called test that is accessable via the URL
"http://myhost.com/test/". In the web.xml file (in the
"webapps/test/WEB-INF" directory) I put the following mapping:
<servlet>
    <servlet-name>router</servlet-name>
    <servlet-class>router</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>router</servlet-name>
    <url-pattern>/*</urlpattern>
</servlet-mapping>

the idea is that I should be able to request the file test.jsp and have
the router servlet pick up the request (to test for a login)...but the
servlet never gets the request... the test.jsp page just comes right
up.... grrrrr...
I'm requesting it with the URL "http://myhost.com/test/test.jsp".
Any ideas/suggestions???
Matt Goss

Re: servlet mappings???

Posted by Matt Goss <mg...@rtci.com>.
Thanks Kurt,
That works great for any (.html) files except .jsp and servlets... why would that
be???
Matt

Kurt Bernhard Pruenner wrote:

> Matt Goss wrote:
> > <servlet-mapping>
> >     <servlet-name>router</servlet-name>
> >     <url-pattern>/*</urlpattern>
> > </servlet-mapping>
> >
> > the idea is that I should be able to request the file test.jsp and have
> > the router servlet pick up the request (to test for a login)...but the
> > servlet never gets the request... the test.jsp page just comes right
> > up.... grrrrr...
>
> I had a similar problem - you might want to try the following:
>
> <servlet-mapping>
>     <servlet-name>router</servlet-name>
>     <url-pattern>/</urlpattern>
> </servlet-mapping>
>
> AFAIK that's how you do it according to the servlet spec... IIRC using the
> postfix "/*" only works on paths below root, i.e. "/somedir/*"...
>
> --
> Kurt Pruenner - Haendelstrasse 17, 4020 Linz, Austria | Briareos at Olymp BBS:
> http://www.mp3.com/Leak http://www.ssw.uni-linz.ac.at | ssh bbs@138.232.112.32
> ...........It might be written "Mindfuck", but it's spelt "L-A-I-N"...........
> np: Burnt Friedman & The Nu Dub Players - I Shot The Fashion Victim
>     (Just Landed)

Re: servlet mappings???

Posted by Matt Goss <mg...@rtci.com>.
hmmmm....

Kurt Bernhard Pruenner wrote:

> Matt Goss wrote:
> > On second thought...
> > when requesting an html file it routed to the servlet (which popped up a
> > login screen) but when the servlet tried to forward to the html file it
> > aparently got caught in a recursive error of some kind and just hung. Then I
> > noticed a huge stack trace dumping out onto the screen of my server...
> > I could only get a section of it but it was the section that kept repeating
>
> You wouldn't possibly have been redirecting to a file in your webapp that's
> also prone to get caught by that servlet mapping? If you did, I guess that's
> gonna cause an endless loop... :/

nope, just a simple hello world page...

>
>
> How about using a subdirectory for forwarding and a different one for the
> files themselves? Of course, this way everybody can access the servlets in the
> second directory directly as well... :/

this is an idea I'll have to try out... although if the mappings are not working
for one directory, I'm not sure how doing it for two will help....
Thanks anyway :)
Matt

Re: servlet mappings???

Posted by Kurt Bernhard Pruenner <le...@gmx.at>.
Matt Goss wrote:
> On second thought...
> when requesting an html file it routed to the servlet (which popped up a 
> login screen) but when the servlet tried to forward to the html file it 
> aparently got caught in a recursive error of some kind and just hung. Then I 
> noticed a huge stack trace dumping out onto the screen of my server...
> I could only get a section of it but it was the section that kept repeating

You wouldn't possibly have been redirecting to a file in your webapp that's
also prone to get caught by that servlet mapping? If you did, I guess that's
gonna cause an endless loop... :/

How about using a subdirectory for forwarding and a different one for the
files themselves? Of course, this way everybody can access the servlets in the
second directory directly as well... :/

-- 
Kurt Pruenner - Haendelstrasse 17, 4020 Linz, Austria | Briareos at Olymp BBS:
http://www.mp3.com/Leak http://www.ssw.uni-linz.ac.at | ssh bbs@138.232.112.32
...........It might be written "Mindfuck", but it's spelt "L-A-I-N"...........
np: Mira Calix - Skin With Me (One On One)

Re: servlet mappings???

Posted by Matt Goss <mg...@rtci.com>.
On second thought...
when requesting an html file it routed to the servlet (which popped up a login
screen) but when the servlet tried to forward to the html file it aparently got
caught in a recursive error of some kind and just hung. Then I noticed a huge
stack trace dumping out onto the screen of my server...
I could only get a section of it but it was the section that kept repeating
<stack trace>
at router.doPost(router.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at
org.apache.tomcat.core.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:163)

</stack trace>
Could this be related to the authentication bug some people have noticed??? I'm
running Tomcat 3.1.
Matt

Kurt Bernhard Pruenner wrote:

> Matt Goss wrote:
> > <servlet-mapping>
> >     <servlet-name>router</servlet-name>
> >     <url-pattern>/*</urlpattern>
> > </servlet-mapping>
> >
> > the idea is that I should be able to request the file test.jsp and have
> > the router servlet pick up the request (to test for a login)...but the
> > servlet never gets the request... the test.jsp page just comes right
> > up.... grrrrr...
>
> I had a similar problem - you might want to try the following:
>
> <servlet-mapping>
>     <servlet-name>router</servlet-name>
>     <url-pattern>/</urlpattern>
> </servlet-mapping>
>
> AFAIK that's how you do it according to the servlet spec... IIRC using the
> postfix "/*" only works on paths below root, i.e. "/somedir/*"...
>
> --
> Kurt Pruenner - Haendelstrasse 17, 4020 Linz, Austria | Briareos at Olymp BBS:
> http://www.mp3.com/Leak http://www.ssw.uni-linz.ac.at | ssh bbs@138.232.112.32
> ...........It might be written "Mindfuck", but it's spelt "L-A-I-N"...........
> np: Burnt Friedman & The Nu Dub Players - I Shot The Fashion Victim
>     (Just Landed)

Re: servlet mappings???

Posted by Kurt Bernhard Pruenner <le...@gmx.at>.
Matt Goss wrote:
> <servlet-mapping>
>     <servlet-name>router</servlet-name>
>     <url-pattern>/*</urlpattern>
> </servlet-mapping>
> 
> the idea is that I should be able to request the file test.jsp and have
> the router servlet pick up the request (to test for a login)...but the
> servlet never gets the request... the test.jsp page just comes right
> up.... grrrrr...

I had a similar problem - you might want to try the following:

<servlet-mapping>
    <servlet-name>router</servlet-name>
    <url-pattern>/</urlpattern>
</servlet-mapping>

AFAIK that's how you do it according to the servlet spec... IIRC using the
postfix "/*" only works on paths below root, i.e. "/somedir/*"...

-- 
Kurt Pruenner - Haendelstrasse 17, 4020 Linz, Austria | Briareos at Olymp BBS:
http://www.mp3.com/Leak http://www.ssw.uni-linz.ac.at | ssh bbs@138.232.112.32
...........It might be written "Mindfuck", but it's spelt "L-A-I-N"...........
np: Burnt Friedman & The Nu Dub Players - I Shot The Fashion Victim 
    (Just Landed)