Hello Ross and everybody!

I have a solution, it is good for IE and NS (all versions)
but mostly not usable with Opera.

I. --------------------------------------------------------------------
I.1) Q:
RL> I have a single servlet, ReportDispatcher, that serves up a wide variety of
RL> reports, some of which are drill-downs from a parent. The parent report is
RL> created by a POST to the servlet from a range selection UI. Unfortunately,
RL> after you go to a drill-down report and then hit the Back button, IE and
RL> Netscape both give a "Page Expired" warning and force you to repost. This
RL> has the additional unfortunate side-effect of requerying the database.

RL> Is there a way to avoid this? I've found a few things on the web, but they
RL> simply say "Don't POST". A GET is a bit impractical, however, since I may be
RL> sending a list of, say, 50-100 departments to include in the query. I tried
RL> the archives, but if there's anything there is must be under far different
RL> search terms than I am using (Page Expired Warning Java servlet HTTP POST).

RL> Is GET the only way out here?

I.2) A1:

Yes and no.
If you convert POST into a get, the user hits the 'Back'
button in a similar situation and then forces the page
he receives to be refreshed (presses Ctrl+R or F5) then
your database still get will be re-queried.

I.3) A2:

The solution:

you submit the page with any method you like (POST or GET,
but POST looks better to me) then process the form and do
a Redirect(). This redirect brings user to some 'renderer'
url. Pages generated by that url maybe have to be marked
as pre-expired (Expires: -1) or Cache-Control: no-cache
or something alike.
Maybe you'll have to pack some data into the session or
(why not?) some hand-made cookie.

I.4) This approach brings one more feature:

if you
1) were at url    /aaa/a.jsp
2) then a form was submitted to /bbb/B
3) and then the user was redirected to /aaa/a.jsp
then in Netscape and Explorer the History
won't contain an extra entry!
Pressing the 'Back' button will bring user where he
was _before_ step 1)!
This has been brought up in the list as a possible
answer to the 'How to disable the "Back" button?'
question lately.

II. ---------------------------------------------------------
II.1) Unfortunantly, this effect ("disabling the 'Back' button')
does not happen with Opera 6 :-(

II.2) Ever worse, setting

Expires: -1
Cache-Control: no-chache
Pragma: no-chache

could not force Opera to reload /aaa/a.jsp
after a page has been submitted to /bbb/B and then a redirect
was sent to /aaa/a.jsp.

(An example. Let us suppose it is a guest-book.

/aaa/a.jsp presents the current records in the guest-book and
           a form to add to the guest-book.
           This page is marked as

           Expires: -1
           Cache-control: no-cache
           Pragma: no-cache

           The form has action="/bbb/B",
           a servlet mapped to /bbb/B
           adds a record to the guestbook database
           and sends a redirect back to /aaa/a.jsp

/aaa/a.jsp Netscape and IE re-request the page from the
           server and the user sees the guest-back with the new record
           just added.
           Opera serves a cached copy of the page and the user
           has to press 'Refresh' to see the new record added
)

This effect looks _very_ sad to me. I do not know how
to make web applications that will work well with Opera at
all because of this :-(((

I think that this method - sending a redirect - is almost perfect:
it saveguards us from resubmitting forms that for example
alter something in a guest book, database, etc - that is that
shouldn't be resubmitted.

To me Opera is quite a good browser. I think that more
standard-compling browsers we have the better. I would like very much
to support Opera in my webapps, but the inability of Opera to honour
Cache-Control: no-cache and Expires: -1 headers break everything for
me :-((

II.3)

Another "feture" of Opera 6 is that when you normally submit a form
from page /aaa/a.jsp to page /bbb/B
by method POST, (without sending any redirect),
see the url /bbb/B in your Opera window,
then press some line that carries for example to
/ccc/c.jsp and then hit the 'Back' button,
then Opera _re-POST-s data without asking you).
(In the same situation Netscapes and IEs bring out a dialog:
"re-POST form data?" This is what this discussion has started with).

--
Best regards,
 Anton Tagunov                            mailto:[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to