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!!!