File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Submitting forms with URL re-writing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Submitting forms with URL re-writing" Watch "Submitting forms with URL re-writing" New topic

Submitting forms with URL re-writing

Hazel Sisson

Joined: Feb 12, 2002
Posts: 17
I am currently building a web application using JSP and servlets, and have successfully implemented session tracking using the HttpSession. I am also using encodeUrl() on each link in case the user has disabled cookies. It works fine until there is a form and the user hits submit, then the session is lost and they are taken back to the login page.
The submit button just uses this javascript ocument.bookDetails.submit() to submit the data, then the form calls a servlet which processes the form data, updates the DB and then calls a new page using requestDispatcher.
Obviously this needs to be changed, but I have no idea what it should be changed to! Is it the servlet that needs to be changed? What do I need to do to maintain the URL re-writing?
Thanks very much,
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
It is the 'action' attribute of the form tag that needs to be encoded.

Hazel Sisson

Joined: Feb 12, 2002
Posts: 17
Thanks Dave.
I agree. Here's the link:
subject: Submitting forms with URL re-writing
jQuery in Action, 3rd edition