Link to home
Start Free TrialLog in
Avatar of nphnhi
nphnhi

asked on

how to get the content output from another servlet?

Hello,
I have 2 servlets, one will test the connection, then using out.println(theresult).
Now, the second servlet will get theresult from the first servlet. How to do it?
Thank you very much
Avatar of aman123_123
aman123_123

You should to forward the request to the the second servlet once the first servlet is done with its processing.
Avatar of nphnhi

ASKER

i found the solution.
how to read directory from URL
import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {
      URL yahoo = new URL("http://www.yahoo.com/");
      BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        yahoo.openStream()));

      String inputLine;

      while ((inputLine = in.readLine()) != null)
          System.out.println(inputLine);

      in.close();
    }
}
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

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