Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Qucik Question


Message #1 by Liming Xu <lxu@t...> on Fri, 11 Jan 2002 11:27:36 -0500
Here is a suggestion based on my limited knowledge of what you are
doing...

First you will need an object that opens up an input stream and
continually appends the COM data into a StringBuffer or some container.
This COM polling would be done in a separate thread that implements the
Runnable interface. Whenever you felt like it, the StringBuffer would
then be processed by whatever means you desire, but make sure
StringBuffer (and any other object fields that may be sensitive inside
this object) are synchronized. Have a servlet get a clone of the buffer
(or processed object) and put it in the request context and forward it
to the JSP page. If you want the JSP page to continually update itself
to display partial results, the servlet could send the page a REFRESH
response header with a refresh time. At the designated time the page
will request an update and the servlet can respond with updated data.

There is an example of creating a page that will automatically refresh
from a process that is running in a separate thread. It is in 'Core
Servlets and JavaServer Pages' from Sun Press by Marty Hall (a great
book) www.coreservlets.com. Download the source code and look at Chapter
7. This doesn't deal with COM ports, but the concept would be similar.

Also, you may want to check out the Java Tech Forums:
http://forum.java.sun.com/ 

Hope this helps,
Kevin


  Return to Index