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
Java EE

Avatar of undefined
Last Comment
Computer101

8/22/2022 - Mon
aman123_123

You should to forward the request to the the second servlet once the first servlet is done with its processing.
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
Computer101

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck