I am creating a client - server application that will process lines like:

startjob
adduser
adduser
adduser
adduser
endjob

adduser can be an unlimited amount of times. I want to process the lines as they come into the Servlet, that way a seperate process could be doing something to complete each of the tasks, while I am in the process of working on reading the lines.

I have written a Socket server of my own to do this before, I am now trying to use Tomcat Servlet to do the same thing, because Tomcat already some behind the scenes stuff already setup.

Does this make sense? Am I totally off my rocker? (My wife would definately agree with that last bit.)

Andre Prasetya wrote:
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 <[EMAIL PROTECTED]> wrote:

Hassan Schroeder wrote:
> On 12/15/06, Scott Carr <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Scott Carr
OpenOffice.org
Documentation Co-Lead
http://documentation.openoffice.org


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

Reply via email to