You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Simon Waddington <wa...@yahoo.com> on 2000/08/23 21:11:41 UTC
Page redirect without HTTP...
Folks,
I'm struggling with how to implement redirecting from a Cocoon page.
The reason for this is to implement a Cocoon page that is pure logic, a
"logic page". A logic page takes some inputs (from form parameters or
elsewhere), does some code execution (say a database query) via XSP, saves
any data that might be required later and then "redirects" to another page in
the application based on the results. The page redirected could be a simple
static "success" or "failure" message, but more often than not will use XSP
to retrieve/transform the data. It might even be another "logic page". This
structure allows me to cleanly separate logic and presentation pages rather
than embed large quantities into each page that mix content/logic. I don't
know if anyone agrees with me that this is a good idea but its what I'm
trying to do.
Now my technical problems are:
1. Using sendRedirect() to go from my logic page to a new page is UGLY and
inefficient, subject to client problems and caching problems etc.
2. What I really want to do is use the servlet engine to redispatch the
request on the server side, but damned if the Apache/JServ that I have to use
doesn't support servlet 2.1 or higher where this would be possible.
3. I wrote a "logic" processor that looks at a PI I add to the page to tell
it what the next page is, it then discards the current document and goes to
that. I also wrote a bunch of code to emulate servlet request attributes so
I can preserve environment between my pages. This works great except where I
redirect to another page with XSP in it. XSP uses the current request object
to get the path of the file to compile and since my code doesn't touch the
request object (it cant) XSP compiles the original file, executes it and
redirects again in an infinite loop.
I don't want to change XSP. I'm stuck with servlet 2.0 (doh!). Is there any
way out?
Thanks in advance,
Simon Waddington.
__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
Re: [Cocoon Users] Page redirect without HTTP...
Posted by Tagunov Anthony <at...@nnt.ru>.
Hello Simon!
Though I'm only a novice in Cocoon, I'm currently solving JUST THE SAME proble as you do.
My approach is as followes: I take the code of latest XInclude processor and provide my own
directive <xecute xecute:xecute href="/some-file.xml">.
Actually I hack Engine.java to split hande method into
prehandle that does evrth handle does in normal Cocoon, except it doesn't try to fetch page from Cache and it doesn't engage formatter.
It returns a DOM tree of objects. (Reprocessed handle calls prehandle and then engages formatter).