cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wirz <michael.w...@abs.de>
Subject Re: Forward to another Servlet from Cocoon
Date Tue, 04 Oct 2005 08:10:04 GMT
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


Mime
View raw message