aspose file tools*
The moose likes Servlets and the fly likes Form values remain in URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Form values remain in URL" Watch "Form values remain in URL" New topic
Author

Form values remain in URL

Gary Seibold
Greenhorn

Joined: Oct 08, 2004
Posts: 7
I hope I can explain this....

I have created portlet with a for to add a value
<FORM>
Gary Seibold
Greenhorn

Joined: Oct 08, 2004
Posts: 7
I wasn't done descriping this...
<FORM>
<INPUT TYPE="text" NAME="ssn">
<INPUT TYPE="submit" NAME="todo" VALUE="ADD">
</FORM>

When the form is submitted I check to see if todo equals ADD and save the value in ssn.

Works ok but when the page is refreshed or another portlet is clicked or submitted, todo still equals ADD and ssn still has a value even tho it is blank on the screen. I think the parameters are stored in several URLs on the page so they hold their value. So I end up with the same ssn bein added many times. How can I prevent this or not have those parameters in URLs?

Thnaks.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Gary,
You have a few ways of dealing with this:
1) Use <form action="post". This won't stop the user from submitting twice, but at least they will be prompted. I suggest doing this anyway, even if you adopt another solution.
2) Store a token in the session when this page is displayed. When the user adds the SS#, delete the token. Only add if the token is there.
3) SS# is unique. You could do a query to see if the SS# is already in your database.
[ November 08, 2004: Message edited by: Jeanne Boyarsky ]

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Welcome to JavaRanch! I've submitted a post without being done quite a few times myself. In fact, it happened right in this thread. Note that we have an edit button (the white rectangle with a pencil) for if this happens in the future.

Since there isn't anything Oracle specific about this question, I'm moving it to our Servlets forum. (This problem occurs all the time, not just in portlets.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form values remain in URL