Execute JSP within a servlet ?  
Author Message
galpix





PostPosted: 2005-8-4 18:31:00 Top

java-programmer, Execute JSP within a servlet ? Hi folks,

A bug in cocoon prevents me from using it with JSP ... so I decided to
do my own implementation. I want to load up and execute a JSP file from
within a servlet, and from the generated XML doc apply an XSL style
sheet, then send back HTML to the browser. This is doable right ? since
a jsp doc somehow gets compiled and executed within a servlet anyway
... Is there an example of how this can be done ?
Also, am I going to miss out on some possible caching that happens
magically when I invoke a jsp directly from the browser ?

Many thanks,

galpi

 
Aquila Deus





PostPosted: 2005-8-4 21:20:00 Top

java-programmer >> Execute JSP within a servlet ? email***@***.com wrote:
> Hi folks,
>
> A bug in cocoon prevents me from using it with JSP ... so I decided to
> do my own implementation. I want to load up and execute a JSP file from
> within a servlet, and from the generated XML doc apply an XSL style
> sheet, then send back HTML to the browser. This is doable right ? since
> a jsp doc somehow gets compiled and executed within a servlet anyway
> ... Is there an example of how this can be done ?
> Also, am I going to miss out on some possible caching that happens
> magically when I invoke a jsp directly from the browser ?

I think you can forward to it. Or use the methods similiar to filter
(then it will return back after jsp is done), but jsp's class naming is
not standardized.

 
galpix





PostPosted: 2005-8-4 23:01:00 Top

java-programmer >> Execute JSP within a servlet ? Thanks Aquilla ...

I found an example of how this can be done. For others who might be
interested :

public void doPost(HttpServletRequest request, HttpServletResponse
response) {
...
try {
String jsp2Call=/jsp/myJsp.jsp";
getServletConfig().getServletContext().getRequestDispatcher(
jsp2Call).forward(request, response); } catch (Exception e)
{.....}
...
}