If I print the value of request.getQueryString() function, it shows the value as "action=getall" but when I do request.getParameter("action"), this returns me a null value. I am not able to figure out why its happening.
The only change I have done in my app is changing the Java URL rewriting (using tuckey urlrewrite.jar file) to Apache mod_rewrite.
The first thing I would do is try it without mod_rewrite. Just hit the servlet container directly.
If the problem doesn't exists when hitting it directly, then you know that that mod_rewrite is not configured properly.
I'm guessing this is the case.
thanks for the reply. I have done the same thing now . I have reverted back mod_rewrite change to use tuckey url rewrite again. And it seems to be working fine now.
Will have to debug the issue with mod_rewrite configuration. Its very strange since I have just compiled the Apache with mod_rewrite module enabled and added the same URL regex which were given in url_rewrite.xml file for Tuckey in the mod_rewrite.conf.
Here is step by step mod_rewrite configuration I have done:
1. Installed apache with mod_rewrite enabled. And configured mod_jk connector to connect to Tomcat.
2. Created new file mod_rewrite.conf inside <APACHE_HOME>/conf directory with below mentioned content
3. Added entry inside conf/httpd.conf file below line
4. Started both Tomcat and Apache server.
The weird part is this problem is coming very randomly and not for the same URLs also. I tried printing the values of request.getParameterMap() which returns empty map, request.getParameterNames() returns empty enumeration even though request.getQueryString() returns "action=getall".
Please let me know in case I have missed something in configuration.
To solve this issue, I put a hot fix in my app. Since I was always getting action parameter in request.getQueryString(), I put the following code:
When I restarted my App, I noticed that none of the parameters which were sent using the POST method were present in the request object. Looks like new request object is getting created some how on the path from Apache to Tomcat and losing all the values which were sent initially.
Still, the URLs failing randomly is unexplainable.
I'm not sure I understand what you're doing, but I just want to make sure you realize that the query string is not the same as the request parameters. When the form action is POST, request parameters will (generally) not be in the query string.
I'll stop here in case I misunderstood what you meant.
Yes you are right that request.getQueryString() method will return only GET request parameters.
Since initially I thought the problem is with just one parameter which was added through rewrite rule:
Step 1: My app gets a POST request from the calling client (which sends another parameters in POST request) in the form of http://my.apache.com:8080/test/get Step 2: Apache mod_rewrite parse the above URL and send the newly created URL /TestServlet?action=get to the Tomcat.
Step 3. When the request reaches tomcat, when I print request.getQueryString() method it returns "action=get", but when I do request.getParameter("action") it returns a null value.
Just for a work around, since I was getting the value of action in QueryString always, I thought of parsing it and get the value of action.
But it did not solve my problem, since other parameters which were sent in POST request are also coming as NULL.