Anders Lindh wrote:
> 
> >> Doing a 'grep -r sendRedirect * | wc -l' on the above app I get 104.
> >> Does this mean I have to write 104 actions? Or is it possible to write a
> >> generic redirect action
> >       If they are all totally different sendRedirect tests, used only once
> >       in individual xsp pages, you may need to write a comprehensive set of
> >       actions. But I expect in reality it will be a lot less than 104.
> >       (without seeing your application. :-) )
> 
> We are using a system with an EJB container in the background, and use
> cocoon to
> build a user interface. And it really works well. The problem is that our
> redirects
> often depend on more complex stuff than just a parameter value, our business
> logic (the
> beans) take care of as much as possible (including verifying more complex
> input), leaving
> the xsp pages quite lean and mean. How can this be done with the C2 sitemap
> architecture
> (actions?), as easily as possible? We may not have 104 redirects, but enough
> not to write
> an action for each...


I generally advocate writing actions as generically as possible.  I also
generally advocate trying not to use redirects.  I know that sometimes it
is not possible--but basically it forces me to think about elegant solutions
without using a hammer to do a screwdriver's job.  Redirects have specific
side affects to them:

* You have a brand new Request object, so anything you wanted to pass via
  Request attributes is gone.  The consequence is more information has to
  be stored in the Session object.

* You are changing your URL.  Sometimes this is the desired affect, so I can't
  fault it.  Other times, it is more desirable to mount a whole form to one
  URL, and iterate through the pages there.  The advantage is that noone can
  short-circuit the form.

* The biggest issue: not all web servers perform redirects equally.  I had
  issues using redirects in early versions of Cocoon2 and IBM WebSphere 3.5.2.
  WebSphere refused to redirect properly.  Many times it is a configuration issue,
  but in this case, the Servlet Container was buggy and did not transform the
  URL correctly.

If you think of ways to minimize redirects, then you can minimize the number
of Actions you have to write.

Another possibility is to create your own protocol.  You wrap your business
logic in session beans (like you are supposed to do anyway), and call them
from an Action.  If an Exception is thrown, you redirect.  Actions can be
parameterized so you can specify three parameters (bean, method, redirect-to)
and the one (1) Action will handle all the dirty work for you.

S/MIME Cryptographic Signature

Reply via email to