Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how do i deal with protected method in super class?

4 views
Skip to first unread message

eugene kim

unread,
Aug 1, 2002, 10:35:42 PM8/1/02
to
i'd like to use

protected String responseMessage() of

public abstract class HttpURLConnection
extends URLConnection

ultimately i 'd like to check if a given url .. for example
www.abc.com/abc/def/j.html
is reachable or not..


here's what i did
-----
public class MyClass extends HttpURLConnection {
public MyClass(URL u) throws IOException{
super(u);
}
public String getResponseMessage()
throws IOException{
String result = super.getResponseMessage();
System.out.println(result);
return result;
}
........
.....
...
--------------

public class HelloWorld extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
URL tmpURL = new URL("HTTP", "beautifulmind.homelinux.org
", 80, "/index.html");
System.out.println(tmpURL);
MyClass a = new MyClass(tmpURL);
String responseMsgs = a.getResponseMessage();

out.println(ServletUtilities.headWithTitle("yo") +
"<body>\n"+
"\n responseMsgs: " + responseMsgs + "<br>\n" +
"</body></html>");
}
}


here's error msg..
========================
Internal Servlet Error:

java.net.UnknownServiceException: protocol doesn't support input
at java.net.URLConnection.getInputStream(URLConnection.java:666)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:237)

at java.net.HttpURLConnection.getResponseMessage(HttpURLConnection.java:303)
at practice.MyClass.getResponseMessage(MyClass.java:12)
at practice.HelloWorld.doGet(HelloWorld.java:21)

0 new messages