Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java Applet pulling info from a servlet

  • 18-11-2011 10:07PM
    #1
    Registered Users, Registered Users 2 Posts: 862 ✭✭✭


    Hi,
    I'm trying to do some applet/servlet communication. My applet requests info from the servlet and stores it in a variable. I can do this fine for pulling one value from the servlet, but can't do it for many. Here's what I'm doing. My applet connects to serlvet and pulls data as follows....

    URL url = new URL("http://localhost:8084/Project/TestServlet");
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    InputStream in = con.getInputStream();
    DataInputStream result = new DataInputStream(new BufferedInputStream(in));
    String rec = result.readLine();
    // Return the retrieved string
    return rec;

    My servlet just does a println like this....

    out.println("Hello");

    So I end up in my Applet with a String rec, which contains Hello.

    I'd like to be able to open the connection to the servlet, do 10 println's in the servlet - and store these to 10 variables in the applet.
    Can't figure out how to do this.
    Any help much appreciated.


Advertisement