cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: Redirecting
Date Fri, 09 Jul 2004 08:27:32 GMT
   Date: 2004-07-09T01:27:32
   Editor: DavidCrossley <crossley@apache.org>
   Wiki: Cocoon Wiki
   Page: Redirecting
   URL: http://wiki.apache.org/cocoon/Redirecting

   removed junk attachment

Change Log:

------------------------------------------------------------------------------
@@ -1,20 +1,20 @@
-{{{
-Michael Edge wrote:
-
-> It seems to me that the following code will not work in Cocoon 2. 
-> I believe it works in Cocoon 1, but for some reason the request
-> and response objects available within XSP for Cocoon 2 are not
-> HttpServletRequest and HttpServletResponse objects, but rather
-> some cocoon equivalents, org.apache.cocoon.environment.Response
-> and org.apache.cocoon.environment.Request. Unfortunately these
-> new classes do not include the sendRedirect method. Any ideas
-> how I would do this? I need to construct a URL in my code
-> and redirect to that URL.
-
-  <xsp:logic>
-    String url = URLEncoder.encode(url + whatever + parameters);
-    response.sendRedirect(url);
-  </xsp:logic>
+{{{
+Michael Edge wrote:
+
+> It seems to me that the following code will not work in Cocoon 2. 
+> I believe it works in Cocoon 1, but for some reason the request
+> and response objects available within XSP for Cocoon 2 are not
+> HttpServletRequest and HttpServletResponse objects, but rather
+> some cocoon equivalents, org.apache.cocoon.environment.Response
+> and org.apache.cocoon.environment.Request. Unfortunately these
+> new classes do not include the sendRedirect method. Any ideas
+> how I would do this? I need to construct a URL in my code
+> and redirect to that URL.
+
+  <xsp:logic>
+    String url = URLEncoder.encode(url + whatever + parameters);
+    response.sendRedirect(url);
+  </xsp:logic>
 }}}
 
 Reply:
@@ -36,30 +36,27 @@
 
 I wanted to redirect according to a URL provided in one of the XML documents being processed;
something like this:
 
-{{{
-  <map:match pattern="my-resource">
-    ...
-    <map:transform type="special-transformer"/>
-    <map:redirect-to uri="{request-attr:my-parameter}"/>
-  </map:match>
+{{{
+  <map:match pattern="my-resource">
+    ...
+    <map:transform type="special-transformer"/>
+    <map:redirect-to uri="{request-attr:my-parameter}"/>
+  </map:match>
 }}}
 
 Here, the "special-transformer" would be based on AbstractDOMTransformer and set request
attributes when it saw various things in the document. Unfortunately, the redirect is "precalculated"
and the desired value for "my-parameter" never gets used.
 
 So what I did instead was to use some arguably nasty code in my "special-transformer" to
set the redirect:
 
-{{{
-import org.apache.cocoon.environment.Response;
-import org.apache.cocoon.environment.http.HttpResponse;
-
-  // ...
-
-  if (response instanceof HttpResponse) {
-    ((HttpResponse) response).sendPermanentRedirect(target);
-  }
+{{{
+import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.environment.http.HttpResponse;
+
+  // ...
+
+  if (response instanceof HttpResponse) {
+    ((HttpResponse) response).sendPermanentRedirect(target);
+  }
 }}}
 
 This isn't nice, but there really doesn't seem to be any sane way in "vanilla" Cocoon where
sitemap actions can be influenced by the content being processed. I don't want to use !FlowScript,
XSP or any of the peripherals.
-[[BR]]
-[[BR]]
-'''Attachment:''' attachment:cambios+inversion+on+line.txt [[BR]]

Mime
View raw message