When you connect to this address. you receive um http command (302) to redirect to www.yahoo.com. I don't know what does the URL implementantion do in this case but, I think that the problem is in this feature. Try to connect to www.yahoo.com.
Let me know the results. OK!
[]'s
Luciano da Silva Coelho
Sun Certified Programmer for the JAVA2
e-Sec Data Security Technology
[EMAIL PROTECTED]
----------
De: Yang XIAO[SMTP:[EMAIL PROTECTED]]
Responder: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology.
Enviada: Quinta-feira, 13 de Janeiro de 2000 08:28
Para: [EMAIL PROTECTED]
Assunto: [servlet] talk to a URL!!
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> " +
"<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> " +
"<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
