You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Joe Kramer <cc...@gmail.com> on 2007/07/17 14:51:19 UTC

Hot to access raw POST Data in servlet?

Hello,

I can't find a way to do a simple thing - access raw postdata in
servlet service()/doPost() method. (The data that goes after the
headers.)
In old Servlet API it was possible using
javax.servlet.http.HttpUtils.parsePostData() which is now deprecated.
Servlet API only seem to have methods to access request parameters and
properties in HttpServletRequest, but not the request data itself.

What is the best/pssible practice to do that?

Thanks.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Hot to access raw POST Data in servlet?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Have a look here:

http://javawebparts.sourceforge.net

...more specifically this:

http://javawebparts.sourceforge.net/javadocs/javawebparts/request/RequestHelpers.html

...the getBodyContent() is, I think, what your looking for.

hth,
Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Tue, July 17, 2007 2:55 pm, Johnny Kewl wrote:
>
> ----- Original Message -----
> From: "Joe Kramer" <cc...@gmail.com>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Tuesday, July 17, 2007 2:51 PM
> Subject: Hot to access raw POST Data in servlet?
>
>
>> Hello,
>>
>> I can't find a way to do a simple thing - access raw postdata in
>> servlet service()/doPost() method. (The data that goes after the
>> headers.)
>> In old Servlet API it was possible using
>> javax.servlet.http.HttpUtils.parsePostData() which is now deprecated.
>> Servlet API only seem to have methods to access request parameters and
>> properties in HttpServletRequest, but not the request data itself.
>>
>> What is the best/pssible practice to do that?
>
> Joe, I'm far too young to remember this function, so just slap me around
> if
> I dont get it ;)
> If all that function gave you was a HashTable of parameters then wont
> "getParameterNames" be good enough?
> Ie you can enumerate through them find the parameters and the values...
> like
> this
>
>         Enumeration paramNames = request.getParameterNames();
>         while(paramNames.hasMoreElements()){
>             paramName = (String)paramNames.nextElement();
>             paramValue = request.getParameter(paramName);
>         }
>
> or you could use getParameterMap.... if you looking for something close to
> the old HashTable.
> getInputStream... will give you the raw stream.
>
> Young guys like me, use the Enumeration... its handy when you have more
> than
> one submit button ;)
>
>
>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Hot to access raw POST Data in servlet?

Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message ----- 
From: "Joe Kramer" <cc...@gmail.com>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, July 17, 2007 2:51 PM
Subject: Hot to access raw POST Data in servlet?


> Hello,
>
> I can't find a way to do a simple thing - access raw postdata in
> servlet service()/doPost() method. (The data that goes after the
> headers.)
> In old Servlet API it was possible using
> javax.servlet.http.HttpUtils.parsePostData() which is now deprecated.
> Servlet API only seem to have methods to access request parameters and
> properties in HttpServletRequest, but not the request data itself.
>
> What is the best/pssible practice to do that?

Joe, I'm far too young to remember this function, so just slap me around if
I dont get it ;)
If all that function gave you was a HashTable of parameters then wont
"getParameterNames" be good enough?
Ie you can enumerate through them find the parameters and the values... like
this

        Enumeration paramNames = request.getParameterNames();
        while(paramNames.hasMoreElements()){
            paramName = (String)paramNames.nextElement();
            paramValue = request.getParameter(paramName);
        }

or you could use getParameterMap.... if you looking for something close to
the old HashTable.
getInputStream... will give you the raw stream.

Young guys like me, use the Enumeration... its handy when you have more than 
one submit button ;)



> Thanks.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org