Link to home
Start Free TrialLog in
Avatar of gaillard
gaillard

asked on

URLConnection in applet called by Netscape

My applet call a servlet with POST method using this code :

URL u = new URL (buf.toString()) ; //buf is the url of the servlet
URLConnection uc = u.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
PrintWriter out = new PrintWriter(uc.getOutputStream());
out.print(.....)); //put the parameters
out.close();
DataInputStream in = new DataInputStream (new BufferedInputStream(uc.getInputStream())) ;

Netscape 4.7 seems to don't like this code, the java console tells me :
java.io.IOException: <null>
  at netscape.net.URLConnection.connect(Compiled Code)
* at netscape.net.URLConnection.getInputStream(Compiled Code)
  at Ade.AppletTree.initTree(Compiled Code)....

I think uc.getInputStream() is to recent Java to be understood by the JVM of Netscape 4.7.
Can I replace uc.getInputStream() by something to have a better result. I've already tried to call the servlet with GET method but one of my parameters is to big.

Thanks for help.
Gaillard
Avatar of Mick Barry
Mick Barry
Flag of Australia image

> I think uc.getInputStream() is to recent Java to be understood by the JVM

It's calling it ok, so it's found it.


Check your URL, it may not be connecting ok.
Print out the url being used, and try entering it directly in browser.
ASKER CERTIFIED SOLUTION
Avatar of Ovi
Ovi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gaillard
gaillard

ASKER

Thanks, There is a sample code in the discution which is  likely that mine but with the line :

con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

when I insert it in my code, it works.

Just one question, what does this line means?
it meens that the stream is URLEncoded string