Hi, there

I wrote a servlet to talk to a URL, but I just got null from the URL.
Appreciate it if anyone can tell me why?


thanks!!
Stella
public class GetData extends HttpServlet {
    URLConnection connection;

    public void init() throws ServletException{
        try {
            URL url = new URL("http://yahoo.com");
            connection = url.openConnection();
            connection.setDoOutput(true);
        }catch(MalformedURLException me)
            {System.out.println("Could not find URL "+ me);}
        catch(IOException ie) {}
    }

    public void doGet (HttpServletRequest request,
                       HttpServletResponse response)
        throws ServletException, IOException
    {
        // set content type and other response header fields first
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        String pegReturn = request.getQueryString();

        // then write the response
        out.println("<html>" +
                    "<head><title>Get Data Servlet</title></head>" +
                    "<body  bgcolor=\"#FFFFFF\">" +
                    "<center>" +
                    "<hr> <br> &nbsp;" +
                    "<h1>" +
                "<font size=\"+3\" color=\"red\">Get Data </font>" +
                "<font size=\"+3\" color=\"purple\">Servlet</font>" +
                "</h1>" +
                "</center>");

        //Print out the information obtained
           out.println("<center>" +
                        "<hr> <br> &nbsp;" +
                        "<h2>pegreturn:  " + pegReturn + "</h2>" +
                        "</center>");
            out.println("</body></html>");
            out.close();
   }
...
}











______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to