You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Billy V. Kantartzis" <vk...@essex.ac.uk> on 2002/07/29 14:59:16 UTC

forwarding to a jsp using a servlet

can some one please tell me how i coulod make a forward from a servlet to a
jsp i need to use the same url plus 
i dont want in some cases the destination address apiasring on the address
bar 


thanks in advance 
Billy 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: forwarding to a jsp using a servlet

Posted by Andy Eastham <an...@gliant.com>.
Billy,

Sorry - I included my File Utility class by mistake.  I hard coded the
result in the message and still left the method call - doh.

Try again:
String url =  "/WEB_INF/jspDir/test.jsp";
response.setContentType("text/html");
ServletContext sc =  setServletContext();
RequestDispatcher rd =  sc.getRequestDispatcher(url);
rd.include(request, response);

Andy


> -----Original Message-----
> From: Billy V. Kantartzis [mailto:vkanta@essex.ac.uk]
> Sent: 29 July 2002 15:11
> To: Tomcat Users List
> Subject: RE: forwarding to a jsp using a servlet
>
>
>
> thanks i will try this
> -------Original Message-------
>
> From: Tomcat Users List
> Date: 29 July 2002 14:46:04
> To: Tomcat Users List
> Subject: RE: forwarding to a jsp using a servlet
>
> Billy,
>
> Try this in your doGet / process method:
> (I put my jsps under WEB-INF so they are not servable directly).
>
> String url =ileUtil.makeJspUrl("/WEB_INF/jspDir/test.jsp);
> response.setContentType("text/html");
> ServletContext sc =etServletContext();
> RequestDispatcher rd =c.getRequestDispatcher(url);
> rd.include(request, response);
>
> Andy
>
> > -----Original Message-----
> > From: Billy V. Kantartzis [mailto:vkanta@essex.ac.uk]
> > Sent: 29 July 2002 13:59
> > To: Tomcat Users List
> > Subject: forwarding to a jsp using a servlet
> >
> >
> > can some one please tell me how i coulod make a forward from a
> > servlet to a
> > jsp i need to use the same url plus
> > i dont want in some cases the destination address apiasring on
> the address
> > bar
> >
> >
> > thanks in advance
> > Billy
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache
> org>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: forwarding to a jsp using a servlet

Posted by "Billy V. Kantartzis" <vk...@essex.ac.uk>.
thanks i will try this 
-------Original Message-------

From: Tomcat Users List
Date: 29 July 2002 14:46:04
To: Tomcat Users List
Subject: RE: forwarding to a jsp using a servlet

Billy,

Try this in your doGet / process method:
(I put my jsps under WEB-INF so they are not servable directly).

String url = FileUtil.makeJspUrl("/WEB_INF/jspDir/test.jsp);
response.setContentType("text/html");
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.include(request, response);

Andy

> -----Original Message-----
> From: Billy V. Kantartzis [mailto:vkanta@essex.ac.uk]
> Sent: 29 July 2002 13:59
> To: Tomcat Users List
> Subject: forwarding to a jsp using a servlet
>
>
> can some one please tell me how i coulod make a forward from a
> servlet to a
> jsp i need to use the same url plus
> i dont want in some cases the destination address apiasring on the address
> bar
>
>
> thanks in advance
> Billy
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>



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

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: forwarding to a jsp using a servlet

Posted by Will Hartung <wi...@msoft.com>.
From: "Andy Eastham" <an...@gliant.com>
Sent: Monday, July 29, 2002 6:43 AM
Subject: RE: forwarding to a jsp using a servlet


> Try this in your doGet / process method:
> (I put my jsps under WEB-INF so they are not servable directly).
>
>    String url = FileUtil.makeJspUrl("/WEB_INF/jspDir/test.jsp);
>    response.setContentType("text/html");
>    ServletContext sc = getServletContext();
>    RequestDispatcher rd = sc.getRequestDispatcher(url);
>    rd.include(request, response);

Just an FYI in case it ever happens to you, BEA Weblogic will NOT serve JSPs
from WEB-INF, and this can become a porting issue if you ever try to move
your application in that direction.

This particularly notable for things like 'includes'.

I can see how the spec could be read either way, it's a point that should be
clarified in the future, IMHO.

Regards,

Will Hartung
(willh@msoft.com)





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: forwarding to a jsp using a servlet

Posted by Andy Eastham <an...@gliant.com>.
Billy,

Try this in your doGet / process method:
(I put my jsps under WEB-INF so they are not servable directly).

   String url = FileUtil.makeJspUrl("/WEB_INF/jspDir/test.jsp);
   response.setContentType("text/html");
   ServletContext sc = getServletContext();
   RequestDispatcher rd = sc.getRequestDispatcher(url);
   rd.include(request, response);

Andy

> -----Original Message-----
> From: Billy V. Kantartzis [mailto:vkanta@essex.ac.uk]
> Sent: 29 July 2002 13:59
> To: Tomcat Users List
> Subject: forwarding to a jsp using a servlet
>
>
> can some one please tell me how i coulod make a forward from a
> servlet to a
> jsp i need to use the same url plus
> i dont want in some cases the destination address apiasring on the address
> bar
>
>
> thanks in advance
> Billy
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>