You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by pawan <pa...@apar.com> on 2003/05/16 14:17:31 UTC

Problem with servlet mapping.

Hello

I am using Tomcat 4.1.24, Win 2000

In my web.xml file I have ...

    <servlet>
		<servlet-name>
			Controller
		</servlet-name>
		<servlet-class>
			sample.Controller
		</servlet-class>
		<load-on-startup>
			-1
		</load-on-startup>
    </servlet>

    <servlet-mapping>
		<servlet-name>
			Controller
		</servlet-name>
		<url-pattern>
			/shyam/*
		</url-pattern>
    </servlet-mapping>

I have restarted tomcat.

Now in my jsp page i am calling a link

<a href=shyam/catalog.jsp>my catalog</a>

Then it should transfer the handling to my controller servlet. which is in
WEB-INF/classes/sample directory

but i see 404 error. Obviously i don't have any folder called "shyam" becas
this i am using only for url mapping.

Please let me know what i am missing??


Thanks & Regards
Pawan


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


(Solved!!!)RE: Problem with servlet mapping.

Posted by pawan <pa...@apar.com>.
Thanks Bill...

it worked... but it will be great if you please explain me why?? or any
related resource?

Pawan


-----Original Message-----
From: news [mailto:news@main.gmane.org]On Behalf Of Bill Barker
Sent: Saturday, May 17, 2003 10:27 AM
To: tomcat-user@jakarta.apache.org
Subject: Re: Problem with servlet mapping.


It should work if the JSP URL is in the top-level directory of the web-app.
Otherwise, you need to change your code to something like:
<a href="<%= request.getContextPath() %>/shyam/catalog.jsp">...</a>

"pawan" <pa...@apar.com> wrote in message
news:01c501c31ba5$21775b90$c00010ac@atl.mdc.apar.com...
> Hello
>
> I am using Tomcat 4.1.24, Win 2000
>
> In my web.xml file I have ...
>
>     <servlet>
> <servlet-name>
> Controller
> </servlet-name>
> <servlet-class>
> sample.Controller
> </servlet-class>
> <load-on-startup>
> -1
> </load-on-startup>
>     </servlet>
>
>     <servlet-mapping>
> <servlet-name>
> Controller
> </servlet-name>
> <url-pattern>
> /shyam/*
> </url-pattern>
>     </servlet-mapping>
>
> I have restarted tomcat.
>
> Now in my jsp page i am calling a link
>
> <a href=shyam/catalog.jsp>my catalog</a>
>
> Then it should transfer the handling to my controller servlet. which is in
> WEB-INF/classes/sample directory
>
> but i see 404 error. Obviously i don't have any folder called "shyam"
becas
> this i am using only for url mapping.
>
> Please let me know what i am missing??
>
>
> Thanks & Regards
> Pawan




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Problem with servlet mapping.

Posted by Bill Barker <wb...@wilshire.com>.
It should work if the JSP URL is in the top-level directory of the web-app.
Otherwise, you need to change your code to something like:
<a href="<%= request.getContextPath() %>/shyam/catalog.jsp">...</a>

"pawan" <pa...@apar.com> wrote in message
news:01c501c31ba5$21775b90$c00010ac@atl.mdc.apar.com...
> Hello
>
> I am using Tomcat 4.1.24, Win 2000
>
> In my web.xml file I have ...
>
>     <servlet>
> <servlet-name>
> Controller
> </servlet-name>
> <servlet-class>
> sample.Controller
> </servlet-class>
> <load-on-startup>
> -1
> </load-on-startup>
>     </servlet>
>
>     <servlet-mapping>
> <servlet-name>
> Controller
> </servlet-name>
> <url-pattern>
> /shyam/*
> </url-pattern>
>     </servlet-mapping>
>
> I have restarted tomcat.
>
> Now in my jsp page i am calling a link
>
> <a href=shyam/catalog.jsp>my catalog</a>
>
> Then it should transfer the handling to my controller servlet. which is in
> WEB-INF/classes/sample directory
>
> but i see 404 error. Obviously i don't have any folder called "shyam"
becas
> this i am using only for url mapping.
>
> Please let me know what i am missing??
>
>
> Thanks & Regards
> Pawan




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: (Solved: Problem with servlet mapping.

Posted by pawan <pa...@apar.com>.
Thanks Jake. I got it.

-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]
Sent: Monday, May 19, 2003 12:28 PM
To: Tomcat Users List
Subject: Re: (Solved: Problem with servlet mapping.



Are you sure you didn't have the original URL like the following?....

<a href="/shyam/catalog.jsp">blah</a>

If you did, then you basically hardcoded the URL to point to the root of

the server rather than picking up the context via a relative URL.  Or, 
another case might be if you used a relative URL ( "shyam/catalog.jsp"
), 
but  you called this URL from somewhere other than the root of your 
context.  Either case would have given you a 404 error.  Specifically 
prepending the context path to the beginning of your URL is the smartest

thing to do since you never have to worry about either of the above 
mentioned cases.  You always point to the right place no matter what.

Jake


At 11:58 AM 5/19/2003 +0530, you wrote:
>Actually i got a answer for this and i tried
>
><a href="<%= request.getContextPath() %>/shyam/catalog.jsp">...</a>
>
>in the link and its working :-)
>
>but still trying to figure out why its working???
>
>Any idea??
>
>Pawan
>
>-----Original Message-----
>From: Jacob Kjome [mailto:hoju@visi.com]
>Sent: Monday, May 19, 2003 11:52 AM
>To: Tomcat Users List
>Subject: RE: Problem with servlet mapping.
>
>
>
>Tomcat adds this mapping in its web.xml which your app inherits.  It is
>probably a matter of a collision of servlet mappings and the .jsp
>servlet
>mapping is winning out.
>
>Jake
>
>At 10:56 AM 5/19/2003 +0530, you wrote:
> >But in my web.xml i am not specifying .jsp anywhere. I am using url
>pattern
> >/shyam/ ... so i thought if tomcat will see any url pattern like this
>it
> >will redirect that request to Controller Servlet.
> >
> >Thanks
> >
> >Pawan
> >
> >-----Original Message-----
> >From: Jacob Kjome [mailto:hoju@visi.com]
> >Sent: Friday, May 16, 2003 7:20 PM
> >To: Tomcat Users List
> >Subject: Re: Problem with servlet mapping.
> >
> >
> >
> >A .jsp file is not a servlet.  ".jsp" is already an extension that is
> >mapped to the container's jsp servlet.  Your servlet controller would
>be
> >
> >for intercepting servlet requests, not jsp requests.  You should be
> >calling
> >a servlet and forwarding to a .jsp for presentation, not the other
way
> >around.
> >
> >Jake
> >
> >At 05:47 PM 5/16/2003 +0530, you wrote:
> > >Hello
> > >
> > >I am using Tomcat 4.1.24, Win 2000
> > >
> > >In my web.xml file I have ...
> > >
> > >     <servlet>
> > >                 <servlet-name>
> > >                         Controller
> > >                 </servlet-name>
> > >                 <servlet-class>
> > >                         sample.Controller
> > >                 </servlet-class>
> > >                 <load-on-startup>
> > >                         -1
> > >                 </load-on-startup>
> > >     </servlet>
> > >
> > >     <servlet-mapping>
> > >                 <servlet-name>
> > >                         Controller
> > >                 </servlet-name>
> > >                 <url-pattern>
> > >                         /shyam/*
> > >                 </url-pattern>
> > >     </servlet-mapping>
> > >
> > >I have restarted tomcat.
> > >
> > >Now in my jsp page i am calling a link
> > >
> > ><a href=shyam/catalog.jsp>my catalog</a>
> > >
> > >Then it should transfer the handling to my controller servlet.
which
>is
> >in
> > >WEB-INF/classes/sample directory
> > >
> > >but i see 404 error. Obviously i don't have any folder called
"shyam"
> >becas
> > >this i am using only for url mapping.
> > >
> > >Please let me know what i am missing??
> > >
> > >
> > >Thanks & Regards
> > >Pawan
> > >
> > >
> >
>---------------------------------------------------------------------
> > >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail:
tomcat-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: (Solved: Problem with servlet mapping.

Posted by Jacob Kjome <ho...@visi.com>.
Are you sure you didn't have the original URL like the following?....

<a href="/shyam/catalog.jsp">blah</a>

If you did, then you basically hardcoded the URL to point to the root of 
the server rather than picking up the context via a relative URL.  Or, 
another case might be if you used a relative URL ( "shyam/catalog.jsp" ), 
but  you called this URL from somewhere other than the root of your 
context.  Either case would have given you a 404 error.  Specifically 
prepending the context path to the beginning of your URL is the smartest 
thing to do since you never have to worry about either of the above 
mentioned cases.  You always point to the right place no matter what.

Jake


At 11:58 AM 5/19/2003 +0530, you wrote:
>Actually i got a answer for this and i tried
>
><a href="<%= request.getContextPath() %>/shyam/catalog.jsp">...</a>
>
>in the link and its working :-)
>
>but still trying to figure out why its working???
>
>Any idea??
>
>Pawan
>
>-----Original Message-----
>From: Jacob Kjome [mailto:hoju@visi.com]
>Sent: Monday, May 19, 2003 11:52 AM
>To: Tomcat Users List
>Subject: RE: Problem with servlet mapping.
>
>
>
>Tomcat adds this mapping in its web.xml which your app inherits.  It is
>probably a matter of a collision of servlet mappings and the .jsp
>servlet
>mapping is winning out.
>
>Jake
>
>At 10:56 AM 5/19/2003 +0530, you wrote:
> >But in my web.xml i am not specifying .jsp anywhere. I am using url
>pattern
> >/shyam/ ... so i thought if tomcat will see any url pattern like this
>it
> >will redirect that request to Controller Servlet.
> >
> >Thanks
> >
> >Pawan
> >
> >-----Original Message-----
> >From: Jacob Kjome [mailto:hoju@visi.com]
> >Sent: Friday, May 16, 2003 7:20 PM
> >To: Tomcat Users List
> >Subject: Re: Problem with servlet mapping.
> >
> >
> >
> >A .jsp file is not a servlet.  ".jsp" is already an extension that is
> >mapped to the container's jsp servlet.  Your servlet controller would
>be
> >
> >for intercepting servlet requests, not jsp requests.  You should be
> >calling
> >a servlet and forwarding to a .jsp for presentation, not the other way
> >around.
> >
> >Jake
> >
> >At 05:47 PM 5/16/2003 +0530, you wrote:
> > >Hello
> > >
> > >I am using Tomcat 4.1.24, Win 2000
> > >
> > >In my web.xml file I have ...
> > >
> > >     <servlet>
> > >                 <servlet-name>
> > >                         Controller
> > >                 </servlet-name>
> > >                 <servlet-class>
> > >                         sample.Controller
> > >                 </servlet-class>
> > >                 <load-on-startup>
> > >                         -1
> > >                 </load-on-startup>
> > >     </servlet>
> > >
> > >     <servlet-mapping>
> > >                 <servlet-name>
> > >                         Controller
> > >                 </servlet-name>
> > >                 <url-pattern>
> > >                         /shyam/*
> > >                 </url-pattern>
> > >     </servlet-mapping>
> > >
> > >I have restarted tomcat.
> > >
> > >Now in my jsp page i am calling a link
> > >
> > ><a href=shyam/catalog.jsp>my catalog</a>
> > >
> > >Then it should transfer the handling to my controller servlet. which
>is
> >in
> > >WEB-INF/classes/sample directory
> > >
> > >but i see 404 error. Obviously i don't have any folder called "shyam"
> >becas
> > >this i am using only for url mapping.
> > >
> > >Please let me know what i am missing??
> > >
> > >
> > >Thanks & Regards
> > >Pawan
> > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

(Solved: Problem with servlet mapping.

Posted by pawan <pa...@apar.com>.
Actually i got a answer for this and i tried

<a href="<%= request.getContextPath() %>/shyam/catalog.jsp">...</a>

in the link and its working :-)

but still trying to figure out why its working???

Any idea??

Pawan

-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]
Sent: Monday, May 19, 2003 11:52 AM
To: Tomcat Users List
Subject: RE: Problem with servlet mapping.



Tomcat adds this mapping in its web.xml which your app inherits.  It is 
probably a matter of a collision of servlet mappings and the .jsp
servlet 
mapping is winning out.

Jake

At 10:56 AM 5/19/2003 +0530, you wrote:
>But in my web.xml i am not specifying .jsp anywhere. I am using url
pattern
>/shyam/ ... so i thought if tomcat will see any url pattern like this
it
>will redirect that request to Controller Servlet.
>
>Thanks
>
>Pawan
>
>-----Original Message-----
>From: Jacob Kjome [mailto:hoju@visi.com]
>Sent: Friday, May 16, 2003 7:20 PM
>To: Tomcat Users List
>Subject: Re: Problem with servlet mapping.
>
>
>
>A .jsp file is not a servlet.  ".jsp" is already an extension that is
>mapped to the container's jsp servlet.  Your servlet controller would
be
>
>for intercepting servlet requests, not jsp requests.  You should be
>calling
>a servlet and forwarding to a .jsp for presentation, not the other way
>around.
>
>Jake
>
>At 05:47 PM 5/16/2003 +0530, you wrote:
> >Hello
> >
> >I am using Tomcat 4.1.24, Win 2000
> >
> >In my web.xml file I have ...
> >
> >     <servlet>
> >                 <servlet-name>
> >                         Controller
> >                 </servlet-name>
> >                 <servlet-class>
> >                         sample.Controller
> >                 </servlet-class>
> >                 <load-on-startup>
> >                         -1
> >                 </load-on-startup>
> >     </servlet>
> >
> >     <servlet-mapping>
> >                 <servlet-name>
> >                         Controller
> >                 </servlet-name>
> >                 <url-pattern>
> >                         /shyam/*
> >                 </url-pattern>
> >     </servlet-mapping>
> >
> >I have restarted tomcat.
> >
> >Now in my jsp page i am calling a link
> >
> ><a href=shyam/catalog.jsp>my catalog</a>
> >
> >Then it should transfer the handling to my controller servlet. which
is
>in
> >WEB-INF/classes/sample directory
> >
> >but i see 404 error. Obviously i don't have any folder called "shyam"
>becas
> >this i am using only for url mapping.
> >
> >Please let me know what i am missing??
> >
> >
> >Thanks & Regards
> >Pawan
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Problem with servlet mapping.

Posted by Jacob Kjome <ho...@visi.com>.
Tomcat adds this mapping in its web.xml which your app inherits.  It is 
probably a matter of a collision of servlet mappings and the .jsp servlet 
mapping is winning out.

Jake

At 10:56 AM 5/19/2003 +0530, you wrote:
>But in my web.xml i am not specifying .jsp anywhere. I am using url pattern
>/shyam/ ... so i thought if tomcat will see any url pattern like this it
>will redirect that request to Controller Servlet.
>
>Thanks
>
>Pawan
>
>-----Original Message-----
>From: Jacob Kjome [mailto:hoju@visi.com]
>Sent: Friday, May 16, 2003 7:20 PM
>To: Tomcat Users List
>Subject: Re: Problem with servlet mapping.
>
>
>
>A .jsp file is not a servlet.  ".jsp" is already an extension that is
>mapped to the container's jsp servlet.  Your servlet controller would be
>
>for intercepting servlet requests, not jsp requests.  You should be
>calling
>a servlet and forwarding to a .jsp for presentation, not the other way
>around.
>
>Jake
>
>At 05:47 PM 5/16/2003 +0530, you wrote:
> >Hello
> >
> >I am using Tomcat 4.1.24, Win 2000
> >
> >In my web.xml file I have ...
> >
> >     <servlet>
> >                 <servlet-name>
> >                         Controller
> >                 </servlet-name>
> >                 <servlet-class>
> >                         sample.Controller
> >                 </servlet-class>
> >                 <load-on-startup>
> >                         -1
> >                 </load-on-startup>
> >     </servlet>
> >
> >     <servlet-mapping>
> >                 <servlet-name>
> >                         Controller
> >                 </servlet-name>
> >                 <url-pattern>
> >                         /shyam/*
> >                 </url-pattern>
> >     </servlet-mapping>
> >
> >I have restarted tomcat.
> >
> >Now in my jsp page i am calling a link
> >
> ><a href=shyam/catalog.jsp>my catalog</a>
> >
> >Then it should transfer the handling to my controller servlet. which is
>in
> >WEB-INF/classes/sample directory
> >
> >but i see 404 error. Obviously i don't have any folder called "shyam"
>becas
> >this i am using only for url mapping.
> >
> >Please let me know what i am missing??
> >
> >
> >Thanks & Regards
> >Pawan
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

RE: Problem with servlet mapping.

Posted by pawan <pa...@apar.com>.
But in my web.xml i am not specifying .jsp anywhere. I am using url pattern
/shyam/ ... so i thought if tomcat will see any url pattern like this it
will redirect that request to Controller Servlet.

Thanks

Pawan

-----Original Message-----
From: Jacob Kjome [mailto:hoju@visi.com]
Sent: Friday, May 16, 2003 7:20 PM
To: Tomcat Users List
Subject: Re: Problem with servlet mapping.



A .jsp file is not a servlet.  ".jsp" is already an extension that is
mapped to the container's jsp servlet.  Your servlet controller would be

for intercepting servlet requests, not jsp requests.  You should be
calling
a servlet and forwarding to a .jsp for presentation, not the other way
around.

Jake

At 05:47 PM 5/16/2003 +0530, you wrote:
>Hello
>
>I am using Tomcat 4.1.24, Win 2000
>
>In my web.xml file I have ...
>
>     <servlet>
>                 <servlet-name>
>                         Controller
>                 </servlet-name>
>                 <servlet-class>
>                         sample.Controller
>                 </servlet-class>
>                 <load-on-startup>
>                         -1
>                 </load-on-startup>
>     </servlet>
>
>     <servlet-mapping>
>                 <servlet-name>
>                         Controller
>                 </servlet-name>
>                 <url-pattern>
>                         /shyam/*
>                 </url-pattern>
>     </servlet-mapping>
>
>I have restarted tomcat.
>
>Now in my jsp page i am calling a link
>
><a href=shyam/catalog.jsp>my catalog</a>
>
>Then it should transfer the handling to my controller servlet. which is
in
>WEB-INF/classes/sample directory
>
>but i see 404 error. Obviously i don't have any folder called "shyam"
becas
>this i am using only for url mapping.
>
>Please let me know what i am missing??
>
>
>Thanks & Regards
>Pawan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Problem with servlet mapping.

Posted by Jacob Kjome <ho...@visi.com>.
A .jsp file is not a servlet.  ".jsp" is already an extension that is 
mapped to the container's jsp servlet.  Your servlet controller would be 
for intercepting servlet requests, not jsp requests.  You should be calling 
a servlet and forwarding to a .jsp for presentation, not the other way around.

Jake

At 05:47 PM 5/16/2003 +0530, you wrote:
>Hello
>
>I am using Tomcat 4.1.24, Win 2000
>
>In my web.xml file I have ...
>
>     <servlet>
>                 <servlet-name>
>                         Controller
>                 </servlet-name>
>                 <servlet-class>
>                         sample.Controller
>                 </servlet-class>
>                 <load-on-startup>
>                         -1
>                 </load-on-startup>
>     </servlet>
>
>     <servlet-mapping>
>                 <servlet-name>
>                         Controller
>                 </servlet-name>
>                 <url-pattern>
>                         /shyam/*
>                 </url-pattern>
>     </servlet-mapping>
>
>I have restarted tomcat.
>
>Now in my jsp page i am calling a link
>
><a href=shyam/catalog.jsp>my catalog</a>
>
>Then it should transfer the handling to my controller servlet. which is in
>WEB-INF/classes/sample directory
>
>but i see 404 error. Obviously i don't have any folder called "shyam" becas
>this i am using only for url mapping.
>
>Please let me know what i am missing??
>
>
>Thanks & Regards
>Pawan
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org