• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

SOS!!!!!!!!!!

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic