Suppose I have a generic content handler to handle requst
/step/1, /step/2, ..., /step/n

<Location /step>
      SetHandler perl-script
      PerlHandler MyHandler

</Location>

#MyHandler.pm
package MyHandler;
sub handler {
  my $r=shift;
  my $step = substr($r->path_info(),1);

  #do something before fetch the content

  #fetch content: usually include a form that will assign action
/step/($step+1)

}

So if everything goes well, the user will follow through from step 1, step
2, until fnish.
Now if in the "#do something ..." part, something is wrong, it will usually
require user go back to the same step, for example, to fill the form again.
The way my old cgi script does is just generate the form with prefilled
value plus some error message indicate what's wrong. It works ok but the
browser location will show /step/($step+1) while it actually is /step/$step.
Now that I am working it on mod-perl I thought I should be able to do
something about it. I briefly browsed the 2 mod-perl books (eagle,
cookbook), and could not found a simple solution yet  (or I missed it?). I
was think using one of the folowing might work:z
1) save the request data in a temp file and redirect or http-refresh to
/step/$step?$session_id or /step/$step/error?$session_id
Remember the content is dynamic and depend on the input form data, so simple
redirect may not work.
Looks like Apache will not post the form data when redirect with Location?

2) print a short form with hidden data and assign action=/step/$step/error
then submit right away (onload=form.submit()?)

Does anybody have a simple solution, e.g. without redirect? Is it possible
to change the URI showing in the browser's address/location bar?

I would appreciated if somebody can pointer me to the right direction.

Harry



Reply via email to