• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

java.io.IOException

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends..
I am including my test code which establishes a ssl connection to a server and posts an HTTP Post request .which then sends the response back.
This code works fine with jdk1.3.1_01.
But when i try to run the same code sample on j2sdk1.4.2_02, i get Socket Exception. Unexcpected end of file error just after the System.out.println(hello....10)statement. On searching the net i found there is a bug in URLConnection's getContent Method of j2sdk1.4.2_02....which has been fixed in j2sdk1.4.2_03....so i downladed the same.....and tried to run the same....but now it gives java.io.IOException....
what could be the reason??
pl. throw some light..

String str = connection.getContentType();
System.out.println("hello....10.5"+str);
// get the response body reader
java.lang.Object response = connection.getContent();
java.io.Reader connReader = new java.io.InputStreamReader( (java.io.InputStream) response );
// read the response to the output
while ( (c = connReader.read()) != -1 )
sb.append((char)c);
req.setAttribute("RESP_XML", sb.toString());
}
catch (Exception e)
{
System.out.println("Error:"+e.toString());
req.setAttribute("RESP_XML", e.toString());
}
finally{
try{

if(reader != null)
reader.close();
if(writer != null)
writer.close();
res.setContentType("text/html");
RequestDispatcher dispatcher;
dispatcher = getServletContext().getRequestDispatcher("/abcd.jsp");
dispatcher.forward(req, res);
}
catch (Exception e1) {
System.out.println("MSG:"+e1.toString());
}
}
}
}
 
lusha tak
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help is greatly appreciated....
thanks a lot..
Lusha
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lusha, could you please post the IOException stack trace that is being thrown? That usually helps in defining the problem.
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic