From: paramsethi on 23 Mar 2010 01:58 On Mar 23, 3:26 am, "John B. Matthews" <nos...(a)nospam.invalid> wrote: > In article > <2965be97-e388-4b69-8400-e1c7d0c68...(a)j21g2000yqh.googlegroups.com>, > > > > paramsethi <param.se...(a)gmail.com> wrote: > > On Mar 22, 6:31 pm, "John B. Matthews" <nos...(a)nospam.invalid> wrote: > > > In article > > > <af4ed7d8-859c-40fe-af92-a844ca957...(a)g19g2000yqe.googlegroups.com>, > > > > paramsethi <param.se...(a)gmail.com> wrote: > > > > I am facing this weird problem in my servlet. > > > > > If I print the request.getQueryString() value, I get > > > > "action=getall" but when I do request.getParameter("action"), it > > > > prints NULL value. > > > > > Any pointers to the reason which could be causing this issue will > > > > be great. > > > > What form action method are you using: GET or POST? The method > > > getQueryString() "returns null if the URL does not have a query > > > string." > > > > <http://java.sun.com/webservices/docs/1.6/api/javax/servlet/http/HttpS...()> > > > <http://www.w3.org/TR/html401/interact/forms.html#submit-format> > > [Please do not quote signature lines.] > > > Hi John, > > > Thanks for the reply. The problem here is opposite :(. > > > I see the data in request.getQueryString() method. But when I try to > > get the same parameter using request.getParameter("action") it > > returns me a null value. > > > Its happening intermittently and not always. The only change I have > > done in my App is to use Apache mod_rewrite module to do URL > > rewriting instead of using urlrewritefilter-2.6.0.jar which handles > > URL rewriting in java. > > OK, getParameter() returns null; how about "If the parameter data was > sent in the request body, such as occurs with an HTTP POST request, then > reading the body directly via getInputStream() or getReader() can > interfere with the execution of this method." > > I'm using tomcat 6 and this example and diff: > > <http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/webapps/examples/ > WEB-INF/classes/RequestParamExample.java> > > < out.println(rb.getString("requestparams.params-in-req") + "<br>"); > > out.println(rb.getString("requestparams.params-in-req") > > + " " + request.getQueryString() + "<br>"); > > < out.println("method=POST>"); > > out.println("method=GET>"); > > -- > [Please do not quote signature lines.] Hi John, I reverted back my changes to Tuckey URL rewrite and everything seems to be working fine. The only reason that I could suspect here is, In the mod_rewrite.conf I am using the below mentioned rule: RewriteRule /test/([^/?]+)[?]*(.*) /TestServlet?action=$1 [QSA,L,PT] My request is coming as a POST and action parameter is appended into URL which means it will be a GET. request.getParameter intermittently tries to read from request body as the request type is POST but the action parameter is present in the url. I am not sure if this is actually the reason, because then it should fail for every request but it's failing randomly. Some times all the URLs are successful. :(
From: paramsethi on 24 Mar 2010 12:29 On Mar 23, 10:58 am, paramsethi <param.se...(a)gmail.com> wrote: > On Mar 23, 3:26 am, "John B. Matthews" <nos...(a)nospam.invalid> wrote: > > > > > In article > > <2965be97-e388-4b69-8400-e1c7d0c68...(a)j21g2000yqh.googlegroups.com>, > > > paramsethi <param.se...(a)gmail.com> wrote: > > > On Mar 22, 6:31 pm, "John B. Matthews" <nos...(a)nospam.invalid> wrote: > > > > In article > > > > <af4ed7d8-859c-40fe-af92-a844ca957...(a)g19g2000yqe.googlegroups.com>, > > > > > paramsethi <param.se...(a)gmail.com> wrote: > > > > > I am facing this weird problem in my servlet. > > > > > > If I print the request.getQueryString() value, I get > > > > > "action=getall" but when I do request.getParameter("action"), it > > > > > prints NULL value. > > > > > > Any pointers to the reason which could be causing this issue will > > > > > be great. > > > > > What form action method are you using: GET or POST? The method > > > > getQueryString() "returns null if the URL does not have a query > > > > string." > > > > > <http://java.sun.com/webservices/docs/1.6/api/javax/servlet/http/HttpS...()> > > > > <http://www.w3.org/TR/html401/interact/forms.html#submit-format> > > > [Please do not quote signature lines.] > > > > Hi John, > > > > Thanks for the reply. The problem here is opposite :(. > > > > I see the data in request.getQueryString() method. But when I try to > > > get the same parameter using request.getParameter("action") it > > > returns me a null value. > > > > Its happening intermittently and not always. The only change I have > > > done in my App is to use Apache mod_rewrite module to do URL > > > rewriting instead of using urlrewritefilter-2.6.0.jar which handles > > > URL rewriting in java. > > > OK, getParameter() returns null; how about "If the parameter data was > > sent in the request body, such as occurs with an HTTP POST request, then > > reading the body directly via getInputStream() or getReader() can > > interfere with the execution of this method." > > > I'm using tomcat 6 and this example and diff: > > > <http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/webapps/examples/ > > WEB-INF/classes/RequestParamExample.java> > > > < out.println(rb.getString("requestparams.params-in-req") + "<br>"); > > > out.println(rb.getString("requestparams.params-in-req") > > > + " " + request.getQueryString() + "<br>"); > > > < out.println("method=POST>"); > > > out.println("method=GET>"); > > > -- > > [Please do not quote signature lines.] > > Hi John, > > I reverted back my changes to Tuckey URL rewrite and everything seems > to be working fine. > > The only reason that I could suspect here is, In the mod_rewrite.conf > I am using the below mentioned rule: > > RewriteRule /test/([^/?]+)[?]*(.*) /TestServlet?action=$1 [QSA,L,PT] > > My request is coming as a POST and action parameter is appended into > URL which means it will be a GET. request.getParameter intermittently > tries to read from request body as the request type is POST but the > action parameter is present in the url. > > I am not sure if this is actually the reason, because then it should > fail for every request but it's failing randomly. Some times all the > URLs are successful. :( Finally I came back to mod_rewrite again, as I wanted to implement the same in my app. I tried putting a logic that If request.getParameter("action") comes as null/blank (since I know it will be coming always as per the rules given in mod_rewrite.conf file), parse the request.getQueryString() method and get the value for action. When I restarted my application with the above fix, I noticed that none of the other required parameters which were sent using POST method were present in the request. Looks like some where the original request is getting lost and server is creating a new request object. The intermittent failure of different URLs is still un explainable.
First
|
Prev
|
Pages: 1 2 Prev: JDK version popularity Next: Blank page when starting tomcat from eclipse |