Meaningless Drivel is fun!
The moose likes Servlets and the fly likes URL rewriting with method POST Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "URL rewriting with method POST" Watch "URL rewriting with method POST" New topic

URL rewriting with method POST

Bob Thele

Joined: Aug 12, 2001
Posts: 5
I understand the process of URL encoding quite clearly but need clarification on the following.
For a HTTP GET request the jsessionid parameter is appended to the URL.
What do you do for a HTTP POST request? Is it possible to use URL rewriting with POST requests?
Do you a) encode the ACTION attribute on the FORM tag OR b) include a hidden field on the form called jsessionid and give it the value of request.getsession(false).getId()?
I can't find any detailed information in any of my texts and the servlet 2.3 specification doesn't clarify this.
Can anyone clarify this for me?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
As I recall, URLrewriting works the same for GET and POST. The servlet engine will grab parameters from both the URL and the POSTed data transparently to the programmer.
Give it a try.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Absolutely don't put a hidden form field called jsessionid.

Your container *may* implement the POST URL re-writing in this way (iPlanet comes to mind, even though they call their gxsessionid), and if you have one already in there, it will confuse the container.
Bob Thele

Joined: Aug 12, 2001
Posts: 5
Thanks for your input on this.
I have tried a few examples out & have ascertained that encoding the ACTION form attribute is the way to go.
The hidden field method failed completely.
I agree. Here's the link:
subject: URL rewriting with method POST
It's not a secret anymore!