[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

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
0
gaillard
Asked:
gaillard
  • 2
1 Solution
 
objectsCommented:
> 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.
0
 
OviCommented:
Take a look to his question (is not a PAQ) http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20150455
0
 
gaillardAuthor Commented:
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?
0
 
OviCommented:
it meens that the stream is URLEncoded string
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now