Sure,
Here is the doPost for ConvertToJspServlet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException {
try {
RequestDispatcher rd = request.getRequestDispatcher(
"/jsps" + request.getPathInfo() + ".jsp");
rd.forward(request, response);
} catch (IOException ioE) {
System.out.println(ioE.getMessage());
}
}
We already did the servlet mapping but I would suggest using a starting path to
make it clear that only requests with /convert/ are mapped
<servlet>
<servlet-name>convertToJspServlet</servlet-name>
<servlet-class>my.com.ConvertToJspServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>convertToJspServlet</servlet-name>
<url-pattern>/convert/*</url-pattern>
</servlet-mapping>
Therefore using this code
http://yourserver/convert/webJsp
will render a JSP from
webapps/yourwebapp/jsps/webJsp.jsp
Hope this helps
> -----Original Message-----
> From: Omar Adobati [mailto:[EMAIL PROTECTED]
> Sent: 17 March 2005 12:31
> To: Tomcat Users List
> Subject: Re: web.xml
>
>
> I'm interested in your solution Allistair, can you better explane what
> "my.com.ConvertToJspServlet" need to make real your idea?
> Can you post a little of code as a sample?
>
>
>
> On Thu, 17 Mar 2005 12:26:29 -0000, Allistair Crossley
> <[EMAIL PROTECTED]> wrote:
> > yes, another (more generic) solution would be a similar
> servlet mapping but route all requests to a servlet capable
> of then forwarding to the request URI + .jsp
> >
> > <servlet>
> > <servlet-name>convertToJspServlet</servlet-name>
> > <servlet-class>my.com.ConvertToJspServlet</servlet-class>
> > </servlet>
> >
> > <servlet-mapping>
> > <servlet-name>convertToJspServlet</servlet-name>
> > <url-pattern>/*</url-pattern>
> > </servlet-mapping>
> >
> > In the ConvertToJspServlet servlet you would obtain the
> request.getRequestURI or mapping and use a RequestDispatcher
> to add a .jsp suffix.
> >
> > At least then you don't have to add mappings in web.xml for
> all your JSPs.
> >
> > Just thinking out loud ;) ...
> >
> > > -----Original Message-----
> > > From: Markus Sch�nhaber
> [mailto:[EMAIL PROTECTED]
> > > Sent: 17 March 2005 12:22
> > > To: Tomcat Users List
> > > Subject: Re: web.xml
> > >
> > >
> > > Am Donnerstag, 17. M�rz 2005 13:17 schrieb Omar Adobati:
> > > > I think that he need something working not just only
> with welcome
> > > > pages, or, maybe I have miss understood.
> > > >
> > > On re-reading the OP it seems to me that I misunderstood (and
> > > Allistair
> > > propably too), not you.
> > >
> > > Regards
> > > mks
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > >
> > >
> >
> > <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE>
> > -------------------------------------------------------
> > QAS Ltd.
> > Developers of QuickAddress Software
> > <a href="http://www.qas.com">www.qas.com</a>
> > Registered in England: No 2582055
> > Registered in Australia: No 082 851 474
> > -------------------------------------------------------
> > </FONT>
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Adobati Omar
> [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]