cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Holz <h...@fiz-chemie.de>
Subject Re: How to Redirect/Forward from a Generator.
Date Fri, 23 May 2003 16:16:13 GMT
Victor Batista <vbatista@present-technologies.com> writes:

> 	I am developing a generator which needs to Forward/Redirect the 
> user to other locations. How can I achieve this on the Java code (not on 
> the sitemap.xmap)?
> 
> 	
> 	How can I convert the Cocoon environment classes
> 			org.apache.cocoon.environment.Context;
> 			org.apache.cocoon.environment.Request;
> 			org.apache.cocoon.environment.Response;
> 
> 	to the standard servlet ones:
> 			javax.servlet.http.HttpServletRequest;
> 			.....

You want do do a external redirect (sending 301 or 307 back to the browser)?
You can't access javax.servlet.http.HttpServletRequest directly,
but the cocoon class has all methods you need.

public class MyGenerator extends AbstractGenerator {
  public void generate(..) {
        Response res = (org.apache.cocoon.environment.http.HttpResponse)
                 org.apache.cocoon.environment.ObjectModelHelper.getResponse(super.objectModel);
        res.sendRedirect(location); 

      // generate human friendly html message
      ...
  }
} 
Of course the class cast means, that you can't use the generator in cli mode. 


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message