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.getOutputSt ream());
out.print(.....)); //put the parameters
out.close();
DataInputStream in = new DataInputStream (new BufferedInputStream(uc.get InputStrea m())) ;
Netscape 4.7 seems to don't like this code, the java console tells me :
java.io.IOException: <null>
at netscape.net.URLConnection .connect(C ompiled Code)
* at netscape.net.URLConnection .getInputS tream(Comp iled Code)
at Ade.AppletTree.initTree(Co mpiled 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
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.getOutputSt
out.print(.....)); //put the parameters
out.close();
DataInputStream in = new DataInputStream (new BufferedInputStream(uc.get
Netscape 4.7 seems to don't like this code, the java console tells me :
java.io.IOException: <null>
at netscape.net.URLConnection
* at netscape.net.URLConnection
at Ade.AppletTree.initTree(Co
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, There is a sample code in the discution which is likely that mine but with the line :
con.setRequestProperty("Co ntent-Type ", "application/x-www-form-ur lencoded") ;
when I insert it in my code, it works.
Just one question, what does this line means?
con.setRequestProperty("Co
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
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.