My only guess is the firewall times the connection out on inactivity. So if
the servlet needs to do additional processing before the response is sent and
the time is too long - the firewall might drop the connection.
-Tim
Vineet Chopra wrote:
I am not calling getParameter method, instead request.getInputStream()
to read the incoming XML is the first line of code after a few logging
statements.
Code for the sender servlet is as follows -
URL url = new URL(destinationURL);
URLConnection conn = url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
PrintWriter writer = new PrintWriter(conn.getOutputStream());
writer.println(data.toString());
writer.flush();
writer.close();
BufferedReader reader = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
String aLine;
StringBuffer strBuf = null;
if(reader!=null){
strBuf = new StringBuffer();
while( (aLine = reader.readLine() )!= null){
strBuf.append(readline);
}
reader.close();
}
Code for the receiver servlet -
protected void doGet(HttpServletRequest request,HttpServletResponse
response) throws ServletException, IOException {
StringBuffer xmlData = new StringBuffer("");
try{
BufferedReader reader=new BufferedReader(new
InputStreamReader(request.getInputStream()));
String aLine = "";
while((aLine=reader.readLine())!=null){
xmlData.append(aLine);
}
//exception thrown here.
reader.close();
PrintWriter writer = null;
String rmessage = null;
//build responseXML and assigned to rmessage
if(rmessage!=null){
writer = new PrintWriter(response.getOutputStream());
writer.println(rmessage);
writer.flush();
writer.close();
}
}catch(Exception exp){
exp.printStackTrace();
}
}
-------------------------------------------------------
It all started with getting an IOException: Cannot close the same
input stream twice at line statement : reader.close(). This was raised
because we were using Tomcat 4.0 which uses the deprecated http
connector.
But the root of the problem is that the ServletInputStream itself is
closed, even before building a InputStreamReader object.
Dilemma is that alls working well in the development environment and
only production is giving the problem, thus suspected the firewall.
On Mar 31, 2005 5:02 PM, Tim Funk <[EMAIL PROTECTED]> wrote:
The firewall is not the problem. If you are using
ServletRequest.getInputStream() - you cannot use
ServletRequest.getParameter(). Odds are something is calling getParameter()
which in turn getParameter() reads the input stream and makes it unavailable.
-Tim
Vineet Chopra wrote:
I am using a web application deployed on Tomcat 4.0 to receive and
route incoming XML messages to destination web application
also deployed on Tomcat 4.0. A firewall exists between these servers.
All firewall policies are enabled for incoming and outgoing traffic.
The ServletInputStream is already closed before I use it to create an
object of InputStreamReader. Thus I am not able to read the stream.
I did a snoop on the ports of these server which displayed the relay
of request XML reaching the destination port and invoking the servlet
in the
destination web application but failing to read the XML since the
input stream has been closed.
Can you give me any leads as to how to debug the problem.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]