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 Thu, 21 Dec 2006 06:30:11 GMT
I see, you're thinking in Sockets

Sockets are usually :
1. open connection
2. give start byte
3. keep streaming the job byte
4. give the stop byte

The question is. How long is the number 3 ? how long between the 1st adduser
and the 2nd adduser ? if its very short then you can use put, if not... you
can consider writing a socket server or creating an async servlet, the logic
is
1. Hit the startjob servlet and get a trxid
2. Hit the job servlet with trxid and jobdescription as its parameter, this
servlet will write the jobs and its sequence to database
3. Hit the endjob servlet with trxid as its parameter, this servlet will
commit the whole process.

Make sense ?

On 12/20/06, Scott Carr <scarr@progbits.com> wrote:
>
> 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 <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
> >>
> >>
> >
> >
>
> --
> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
-Andre-

People see things the way they are and say "why ?" I see things that never
were and say "Why not ?"

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