You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Michael Wirz <mi...@abs.de> on 2005/10/04 10:10:04 UTC
Re: Forward to another Servlet from Cocoon
Victor Batista wrote:
> Hello!
>
> I have a web application with a few servlets, one of which extends
> the CocoonServlet. In some cases, I need to forward from the
> CocoonServlet to a different servlet of my web application. How can I
> do this?
>
Hi,
I use the code below in my cocoon-extension.
I dont know if its the direct way to do it since it needs browser
interaction with meta - refresh
but it works well for me.
Michael
public void service(HttpServletRequest arg0, HttpServletResponse
arg1) throws IOException, ServletException
{
if (CONDITION)
super.service(arg0, arg1);
else
setRedirectResponse(arg1, redirectUrl);
}
private void setRedirectResponse(HttpServletResponse response,
String url) throws IOException
{
// set headers before accessing the Writer
response.setContentType("text/html");
response.setBufferSize(8192);
PrintWriter out = response.getWriter();
// then write the response
out.println("<html>" +
"<head>" +
"<title>TITLE</title>" +
"<meta http-equiv=\"refresh\"
content=\"0;url="+url+">" +
"</head>");
out.println("<body></body></html>");
out.close();
}
}
--
abs IT Service GmbH
abs gruppe
Michael Wirz
Entwicklung
Landsberger Straße 57
82266 Stegen am Ammersee
Telefon: +49 (0)8143 999 43
Telefax: +49 (0)8143 999 49
Michael.Wirz@abs.de
www.eFonds24.de
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org