This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

IOException when i close a stream in Applet WHY!!!!

 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet which connects to a servlet which in turn connect to sql.I get the following error however IOEXception at java/io/ObjectOutputStream.close
Thank u all for your time
URL dataURL = new URL("http://servename/Servlet/Serve";);
URLConnection connection = dataURL.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches (false);
connection.setDefaultUseCaches (false);
connection.setRequestProperty ("Content-Type", "application/octet-stream");

ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream());
out.writeObject(getTextField1().getText());
out.flush();
out.close();
out.close();out.close();
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you really closing this stream 3 times? If the stream is already closed, closing it again will produce an exception.
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no sorry im only closing it once I was trying to make it bold and it copied it several times
sorry
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can edit your original post if you like by clicking on the little edit icon at the top of the message (the paper and pencil icon).
As for the exception, can you include the actual output from System.err? Where is the exception getting thrown, and what does the stack trace look like?
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.io.IOException: ServerName//Servlet/Serve
at com/ms/net/net/wininet/http/HttpInputStream.connect
at com/ms/net/net/wininet/http/HttpInputStream.<init>
at com/ms/net/net/wininet/http/HttpURLConnection.createInputStream
at com/ms/net/wininet/WininetURLConnection.getInputStream
at com/net/wininet/http/HttpPostBufferStream.close
at java/io/ObjectOutputStream.close
at t/TestOne.addName
at java/lang/reflect/Method.invoke
at t/ReflectiveAction.actionPerformed
at java/awt/Button.processActionEvent
at java/awt/Button.processEvent
at java/awt/Component.dispatchEventImpl
at java/awt/Component.dispatchEvent
at java/awt/EventDispatchThread.run
 
    Bookmark Topic Watch Topic
  • New Topic