aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes SOS!!!!!!!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "SOS!!!!!!!!!!" Watch "SOS!!!!!!!!!!" New topic
Author

SOS!!!!!!!!!!

Geoffrey Ren
Greenhorn

Joined: Nov 25, 2002
Posts: 18
try
{
String urlString = "http://localhost:8080/esp/SearchLesson";
URL url = new URL(urlString);

int port = url.getPort ();

if (port == -1)
{
port = 80;
}

socket = new Socket(url.getHost (), port);

out = socket.getOutputStream ();
InputStream in = socket.getInputStream();

Writer writer = new OutputStreamWriter (out, "ISO-8859-1");

writer.write ("POST " + url.getFile () + " HTTP/1.0\r\n");

String contentType = "application/x-www-form-urlencoded";

writer.write ("Content-type: " + contentType + "\r\n");

String condition = "userid = 'test'";;

Vector result = new Vector();
ObjectInputStream read = new ObjectInputStream(in);
writer.write ("Content-length: " + condition.length() + "\r\n\n");
writer.write(condition);
writer.flush ();
while ((result = (Vector)read.readObject()) != null)
{
return result;
}
socket.close ();
writer.close();
}
catch (ClassNotFoundException nf)
{
nf.printStackTrace();
}
catch (StreamCorruptedException se)
{
se.printStackTrace();
}
catch (IOException ex)
{
ex.printStackTrace() ;
try
{
if (socket != null)
{
socket.close ();
}
}
catch (IOException ignored)
{
throw new IOException("operation failure");
}
}

which throw the exception:
java.io.StreamCorruptedException: Caught EOFException while reading the stream header
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at com.esp.courseware.util.SCORMUtils.getLessonListByCondition(SCORMUtils.java:368)
at com.esp.gui.fwk.controller.TableViewController.actionPerformed(TableViewController.java:679)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Please help me!!!
Vijayakumar Arya
Ranch Hand

Joined: Jan 27, 2003
Posts: 76
Hi,
Please compile your code with -g option so that you can know at which line of your code has thrown the exception, after doing this we have to trace the root cause of the exception.
Also use


Thanks,<p>Vijay<p>The Hand that gives, Gathers.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: SOS!!!!!!!!!!