From: paramsethi on
Hi All,

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.

Thanks
Param
From: John B. Matthews on
In article
<af4ed7d8-859c-40fe-af92-a844ca957e40(a)g19g2000yqe.googlegroups.com>,
paramsethi <param.sethi(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/HttpServletRequest.html#getQueryString()>
<http://www.w3.org/TR/html401/interact/forms.html#submit-format>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: paramsethi on
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>
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>

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.
From: Mike Schilling on
paramsethi wrote:
> Hi All,
>
> 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.

Does the HTTP request contain a body? If so, it's possible that
getParameter() is looking for the value in the body rather than in the URL.
If not, I have no idea.


From: John B. Matthews on
In article
<2965be97-e388-4b69-8400-e1c7d0c68e56(a)j21g2000yqh.googlegroups.com>,
paramsethi <param.sethi(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")
> + "&nbsp;" + request.getQueryString() + "<br>");

< out.println("method=POST>");
> out.println("method=GET>");

--
[Please do not quote signature lines.]