Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java Applet pulling info from a servlet

Options
  • 18-11-2011 10:07pm
    #1
    Registered Users Posts: 839 ✭✭✭


    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