Re: How to monitor data in a request sent to a Tomcat server?

2006-09-22 Thread Martin Gainty
Instead of InputStream alone Use BufferedReader (with InputStream as a 
parameter) 
then use BufferedReader.readLine to read until the newline
as in this example

  URL url = new URL("http://www.yoururl.com/";);
URLConnection conn = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
conn.getInputStream()));
String inputLine;

//read all of the lines up until newlines
while ((inputLine = in.readLine()) != null) 
System.out.println(inputLine);
in.close();

HTH
M-
*
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



- Original Message - 
From: "lingyan zhu" <[EMAIL PROTECTED]>
To: 
Sent: Friday, September 22, 2006 7:54 PM
Subject: How to monitor data in a request sent to a Tomcat server?


>I have a client application that posts the content of a file using HTTP/1.0 
>POST, to a web application served on a Tomcat server. The client application 
>generates the appropriate HTTP POST header, and writes the header, followed by 
>the content of the file, out to the server using socket.
>  
> There has been a strange intermittent problem, where an extra line feed 
> character ('\n') was sometimes mysteriously added to the beginning of the 
> posted HTTP content. In another word, when I call getInputStream() on the 
> request in the servlet's service() method, the first byte in the stream shows 
> up as linefeed, even though the content of the original file being posted 
> does not starts with line feed.
>  
>  
> It is unlikely a Tomcat problem, but I want to exclude the possibility that 
> Tomcat is somehow adding this line feed under special circumstances. 
> Therefore I want to monitor the entire data stream (including both header and 
> content) that was sent in a request and check whether the data received by 
> Tomcat already contains this extra line feed.
>  
> Does anyone know how  to do this? Or is it possible that Tomcat could be 
> doing anything like this?
> 
>  
> Thanks a lot,
> yan
>  
> -
> Do you Yahoo!?
> Get on board. You're invited to try the new Yahoo! Mail.

How to monitor data in a request sent to a Tomcat server?

2006-09-22 Thread lingyan zhu
I have a client application that posts the content of a file using HTTP/1.0 
POST, to a web application served on a Tomcat server. The client application 
generates the appropriate HTTP POST header, and writes the header, followed by 
the content of the file, out to the server using socket.
  
 There has been a strange intermittent problem, where an extra line feed 
character ('\n') was sometimes mysteriously added to the beginning of the 
posted HTTP content. In another word, when I call getInputStream() on the 
request in the servlet's service() method, the first byte in the stream shows 
up as linefeed, even though the content of the original file being posted does 
not starts with line feed.
  
  
 It is unlikely a Tomcat problem, but I want to exclude the possibility that 
Tomcat is somehow adding this line feed under special circumstances. Therefore 
I want to monitor the entire data stream (including both header and content) 
that was sent in a request and check whether the data received by Tomcat 
already contains this extra line feed.
  
 Does anyone know how  to do this? Or is it possible that Tomcat could be doing 
anything like this?

  
 Thanks a lot,
yan

-
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.