tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andre Prasetya" <andre.prase...@gmail.com>
Subject Re: Servlet with POST Request
Date Wed, 20 Dec 2006 02:56:38 GMT
Why do you want to read POST by using reader ? I only use the stream from
request on a PUT request.


On 12/16/06, Scott Carr <scarr@progbits.com> wrote:
>
> Hassan Schroeder wrote:
> > On 12/15/06, Scott Carr <scarr@progbits.com> wrote:
> >> Does a servlet require the use of a Content-Length for the Reader to be
> >> populated?
> >
> > A pretty cursory test seems to indicate not, but I could just be lucky
> > :-)
> >
> >> ...and I want to read each line as they come in, and handle the
> >> request on
> >> a line by line basis.
> >
> > Have you tried this yet? request.getReader() would seem to cover
> > your situation, assuming this isn't binary data.
> >
> Hm, the reason I asked, is because of a test I ran.  strLine is always
> null.
>
> Using the following code for processRequest:
>
> response.setContentType("text/plain");
>
>         m_out = response.getWriter();
>         m_bufRead = request.getReader();
>
>         while (true) {
>             strLine = m_bufRead.readLine();
>
>             if (strLine != null) {
>                 if (strLine.startsWith("login")) {
>                     ProcessLogin();
>                 } else if (strLine.startsWith("exit")) {
>                     break;
>                 }
>             } else {
>                 try {
>                     Thread.sleep(1000);
>                 } catch (InterruptedException ex) {
>                     ex.printStackTrace();
>                 }
>             }
>         }
>
>         m_bufRead = null;
>         m_out.close();
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
-Andre-

PCs are like air conditioner, if you open Windows, they don't work

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message