JSP forward

Hi all,

I'm trying to forward a request, in a JSP_A, to JSP_B which is in a different context.

This request was forwarded from a servlet to JSP_A.

How can I do this?

In JSP_A, I have something like this

<%

getServletContext().getContext("/a").getRequestDispatcher("/b/c.jsp").forward(request, response);

%>

but this exception is thrown : getOutputStream() has already been called for this response.

Thanks in advance

[484 byte] By [nrmartinsa] at [2007-10-2 17:23:48]
# 1

>getOutputStream() has already been called for this response.

Make sure you do this forwarding as early as possible - before ANY output gets done. Maybe try doing it from a Servlet instead of a JSP?

A JSP picks up the OutputStream by default, so invoking the jsp in a different context might initialize it again - and thus throw an error.

evnafetsa at 2007-7-13 18:40:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...