my dog learned polymorphism*
The moose likes Tomcat and the fly likes Unable to use GET request to post form data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Unable to use GET request to post form data" Watch "Unable to use GET request to post form data" New topic
Author

Unable to use GET request to post form data

Chris Kairns
Greenhorn

Joined: Dec 28, 2009
Posts: 6
Hi,

This sounds a simple problem but bugging me like anything. I have a simple form on a JSP, something like,


We are using tomcat as the J2EE container and the submitted data flows through Apache Http server(I have rewrite rules here) to tomcat.
I am using following rewrite rule


Now, when the data is posted as a GET request, the part, sessionid="sessionkey", in the action URL on the form just disappears and all the data in the form gets appended after "?". If it is a POST request then there is no problem and it works fine. Any idea what can be wrong?

Thank you very much and I really appreciate everybody's time and help.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

crk crkcrk wrote:We are using tomcat as the J2EE container and the submitted data flows through Apache Http server(I have rewrite rules here) to tomcat.

Tomcat is not a fully compliant JEE server rather it's a web container.
Now, when the data is posted as a GET request, the part, sessionid="sessionkey", in the action URL on the form just disappears and all the data in the form gets appended after "?". If it is a POST request then there is no problem and it works fine. Any idea what can be wrong?

I'm not sure I get the first part of that statement but with GET, all the request parameters gets appended to the request URL, that's how it works. (I'm not sure about the rewrite rule though)
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

And you might need to look at the NamingPolicy of JR. And Welcome to JavaRanch
Chris Kairns
Greenhorn

Joined: Dec 28, 2009
Posts: 6
Thank you for pointing me to the Naming Policy.

Regarding the answer, I know what tomcat is and how a GET request is posted, I haven't asked whether tomcat is a J2EE container or web container or how a GET request is posted.

Does anybody know what is the issue in the scenario I have posted above?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Why the complexity of the Apache front end? That's not a configuration that is used much these days.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3816

Chris Kairns wrote:Now, when the data is posted as a GET request, the part, sessionid="sessionkey", in the action URL on the form just disappears and all the data in the form gets appended after "?". If it is a POST request then there is no problem and it works fine. Any idea what can be wrong?

Hmm.. I didn't get that part in the first place, That is, with GET the query string is generated and appended to the URL after "?" so what ever was there previously will not be available (that is the case with you having the "sessionid" value in the action). With POST the action URL kept unchanged as there is no query string in the URL. Is this what you are looking for?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
Bear Bibeault wrote:Why the complexity of the Apache front end? That's not a configuration that is used much these days.

That doesn't match my experience. I actually see that configuration a lot, wth Apache used as SSL terminator, as load-balancer, and for its modules. Sometimes ModRewrite alone -which Chris mentioned- makes it worth using.


Ping & DNS - my free Android networking tools app
Chris Kairns
Greenhorn

Joined: Dec 28, 2009
Posts: 6
Appreciate both of you for the replies !

Bear : This is the configuration that is used in the environment I work in. It may be totally wrong or invalid or not used now a days, but I cannot change it now and I have to follow it.

Vijitha : I don't rememebr exactly now, but I think I have used something the way I am doing now and it had worked for me. But , indirectly you are saying POST my form after generating the URL I want so it willl work fine?

For example,
Instead of relying on GET method use POST and generate the post url using Javascript like,



Or there is other way using the GET request.

Thanks a lot, both of you again, for your time and help !





Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

The syntax is more correctly ";sessionkey=..." (or was it ";jsessionkey=..."?). And I'm not actually sure how that fits in with the actual URL RFC, truthfully, despite its popularity. A number of things are routinely done that aren't actually RFC-compilant.

But that's beside the point. It looks like probably an issue with Apache's mod_rewrite. I'd have to RTF(Apache)M to be able to say what the proper solution (rule encoding) was.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
wood burning stoves
 
subject: Unable to use GET request to post form data
 
Similar Threads
Problem with request.getParameter
Servlet 404 and JkMount configuration - encountered some problem (Apache/Tomcat)
SSLEXT behavior-- rewrite works, page doesn't come up
echo with grep
I have a problem with methods Get and Post