Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with applet error

Status
Not open for further replies.

4345487

Programmer
Dec 31, 2002
132
US



Hi,

I'm trying to call a applet from a html page an get an error

Code:

public void refreshResults( String sourceSelect, String sourceValue, String destSelect, String cgiName ) throws Exception
{

String uri = cgiName + "?source=" + sourceSelect + "&dest=" + destSelect + "&value=" + sourceValue ;
values = new Vector();
descs = new Vector();

java.net.URL url = new java.net.URL( uri );
java.net.URLConnection urlCon = url.openConnection();
ObjectInputStream in = new ObjectInputStream(urlCon.getInputStream());

values = (Vector) in.readObject();
descs = (Vector) in.readObject();

in.close();
}


but I get this error:

java.io.StreamCorruptedException: InputStream does not contain a serialized object

Thanks
 
This line :

ObjectInputStream in = new ObjectInputStream(urlCon.getInputStream());

attempts to create a java object from the the stream - but it is not a serialized java object. What are you expecting it to be and why are you using ObjectInputStream ?

--------------------------------------------------
Free Database Connection Pooling Software
 

Hi,

Thanks for aswering the question:

I'm new to Java and looking for a way to do remote scripting and that code is a sample that I find. I'm a ASP developer and I use Microsoft remote scripting before where I would have a combo box pick something and with out refreshing the page I could fill up another list box and I try to do that with java.
 
So you actually do want to serialize an object on the server and deserialize it on the client ? How are you serializing the desired object ?

--------------------------------------------------
Free Database Connection Pooling Software
 


Yes that is what I want to do but how.

Thanks
 
Well, I think you will have major problems if you serialize Swing/AWT components on a server and then serialize them, send the object to the client, and then deserialize it at the client.

But if you really want to try, then read this tutorial :


--------------------------------------------------
Free Database Connection Pooling Software
 

Thank you. Do you have any recommendations.
 
Just use Swing/AWT in the applet as normal ... I'm not entirely sure what you are trying to do ...

--------------------------------------------------
Free Database Connection Pooling Software
 

I will try that.

This is what I'm trying to do lets said I have an form in that form I have a combo box with countries when I user selects the USA I want with out refreshing the form update a state list box with all of the states and if the choose Canada update the same list box with all the province.

 
But if you are usinf Applets, then there is no "form submission" - the applet is running on the client - you are not submitting a web page to the server - its all running on the client machine, so you can maipulate the graphics device as required. Are you completelt understanding what exactly an applet is ? In MS terms, its similar to an ActiveX control - it has no explicit ineraction with the server really apart from loading the code into the client browser...

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top