On Tue, 29 Aug 2000, Victor Hadianto wrote:

> > >Isn't that interesting? I always thought that the doGet() will be
> > >called instead if the user click on the 'refresh' button.
> >
> > No, it just repeats the previous command
>
> I don't now about other people opinion, but I really think it's
> better when the browser 'Refresh' button just fetch whatever link in
> the text bar. I could not see any benefit of clicking refresh to
> post the last request. This lead to many of the 'interesting
> features' from a lot of sites where the browser ask the unscrupulous
> question whether you want to repost the data (both IE and Netscape)
> have odd messages.
>
> And then again, people with limited experience like myself tend to
> expect the other applications to behave what I think is right, and
> not the other way around.

This is standard browser/HTTP behavior, it's got nothing to do with
servlets.  Maybe from a servlet-developer point of view this might
seem odd (and problematic) to you, but I think to most web users (and
there are a lot more of them than us :-), it is the right behavior.
They may not know about GET/POST, and they probably don't care, they
just want to see the same page they just saw, refreshed.  And if that
page was from a POST, doing a GET won't necessarily work.

Now, in the servlet, there are ways to detect this and handle it
differently.  (Actually, I'm not sure there is a way to specifically
detect a "Refresh"/"Reload", but you can detect a repeat request,
which is similar, and may be sufficient.)  Basically, you can store
something that tells you that the user has been to that page before
(like in the session).  Then you can look for that and act accordingly
when a request comes in.  Check the archives of this list for more
details.


> > Actually, I meant "the same as the POST page" - a servlet can
> > handle both GET and POST. That way the user would never see the
> > difference.
>
> not necessarly, and adept user will see that in the doGet() method
> we pass the parameter on the link, I mean something like this
> /servlet/my_servlet.html?data1=horriblecode

I think he was referring to the result of the request.


> Actually now that I think about it, I really am not sure how do the
> servlet engine handle the parameter in doPost() from the
> form. Transparent as it is from the serlvet programmer, it really
> helps to understand the nitty gritty of servlet.

The "posted" part of the request must be parsed, and the parameters
extracted.  There is a helper function in HttpUtils.java,
parsePostData(), to do this.  But I believe most servlet containers do
this for you automatically on a POST (perhaps depending on the mime
type).  So in that sense whether it was a POST or a GET is transparent
to the servlet -- either way the parameters will be accessible the
same way, via getParameter() et al.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[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