File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes java.net.SocketException : Connection Reset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.net.SocketException : Connection Reset" Watch "java.net.SocketException : Connection Reset" New topic
Author

java.net.SocketException : Connection Reset

Chaitanya Reddy
Greenhorn

Joined: Jun 06, 2002
Posts: 18
Hello everyone,
I am trying to connect to URL through the following code.
u=new URL("http://www.rcsb.org/pdb/cgi/explore.cgi?job=download;pdbId=1KIT;page=;pid=8231059904141&opt=show&format=PDB&pre=1");
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "192.168.36.204");
System.getProperties().put("proxyPort", "80");
u.setDoOutput(true);
u.setUseCaches(true);
theHTML = new DataInputStream(u.openStream());
while ((thisLine = theHTML.readLine()) != null)
{
if(thisLine.startsWith("HELIX"))
{
sb=thisLine;
System.out.println(thisLine);
while ((thisLine = theHTML.readLine())!=null)
{
System.out.println(thisLine);
if(thisLine.startsWith("MASTER"))
{
break;
}
else
{
sb=sb+"\n"+thisLine;
}
}
}
}
It successfully gets connected to the specified URL.But after printing a few lines on to the screen,the program stops by invoking "java.net.SocketException" .How to handle this exception?

And also is there any more efficient mechanism to connect to URLs other than the above one.If so, please write to me.
Please reply me as soon as possible.
Regards,
Chaitanya Reddy
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I would certainly use a BufferedInputStream rather than DataInputStream.
Surely that is not the real code, I dont see setDoOutput in java.net.URL - is that a URLConnection.
Bill
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Chaitanya,
Welcome to JavaRanch!! Please change your name to be compliant with JavaRanch's naming policy. It should not be obviously fictitious.
Your displayed name should be 2 separate names with more than 1 letter each.
We really would prefer that you use your REAL name.
You can change your name: here.
Thanks,
Cindy
[ August 05, 2003: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
Chaitanya Reddy
Greenhorn

Joined: Jun 06, 2002
Posts: 18
Hello William Brogden ,
Thanks for your reply.Yeah u r right Mr.Brogden.I missed out few statements while I was copying from my program.
I will try out your method.
Thanks anyway.
Chaitu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.SocketException : Connection Reset