Craig,
I made the mistake of giving
"/musicshop/servlet/ShoppingServlet/MainJSP.do", instead
of "/musicshop/MainJSP.do". Now, I get "/MainJSP.do" from getServletPath(),
and after truncating ".do", I get what I was looking for.

Is there any way of getting "/MainJSP.do" from
"/musicshop/servlet/ShoppingServlet/MainJSP.do"?  In that case,
I don't have to do servlet mapping in web.xml of the applicaiton.
Thanks,
Sanjay



>From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>     reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Servlet mapping in Model 2 architecture
>Date: Mon, 25 Sep 2000 11:44:56 -0700
>
>Sanjay Sharma wrote:
>
> > Hi all,
> > I'm trying to make the controller servlet mapping work in Model 2
> > architecture,to get the Action class from a hashtable.
> >
> > Here is what I have done.
> >
> > In a JSP file:
> > <form name="shoppingForm"
> >    action="/musicshop/servlet/ShoppingServlet/MainJSP.do"
> >    method="POST">
> >
> > In web.xml of the application (using Tomcat):
> >
> >    <servlet-mapping>
> >         <servlet-name>ShoppingServlet</servlet-name>
> >         <url-pattern>*.do</url-pattern>
> >     </servlet-mapping>
> >
> > In the controller servlet:
> >
> >         String matchPart = req.getServletPath();
> >         System.out.print("Value before truncating: ");
> >         System.out.println(matchPart);
> >         int extension = matchPart.indexOf(".");
> >         if (extension >= 0)
> >            matchPart=matchPart.substring(0, extension);
> >
> > What I get in getServletPath() is /servlet/ShoppingServlet.
> > What am I doing wrong here?
> > Thanks,
> > Sanjay
> >
>
>If "/musicshop" is your context path, that is exactly what you are supposed
>to
>get.  The getServletPath() method returns the part of the request URI,
>after the
>context path, that was used to select which servlet should be executed.
>When using
>extension matching, that means *everything* after the context path, because
>extension matching only happens after the last slash character.
>
>What did you expect to get?
>
>Craig McClanahan
>
>====================
>See you at ApacheCon Europe <http://www.apachecon.com>!
>Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
>Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
>                                     Applications to Tomcat
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to