What's  a good way to verify if the full URL path exist?
I wrote a method  ( isURLValid ) below but it seems like there should be
an easier way and  one time out of 20 throws an OutOfMemoryException (?
also below)
Any help is greatly appreciated
thanks
jeff


  public boolean isURLValid(String strURL){
            boolean status = true;
            try {
                InputStream is;
                URL url = new URL (strURL);
                URLConnection urlc = url.openConnection();
                is = urlc.getInputStream();
                if ( is.available() == 0 ){
                    System.err.println(" URL Template file not found or
is empty: " + strURL);
                    status = false;
                }
                System.err.println("URL/size" + strURL + "/" +
is.available());
                is.close();

            }
            catch (Exception e) {
                System.err.println ("Exception[isURLValid]  Unable to
find " + strURL );
                System.err.println (e.getMessage());
                status = false;
            }
           return status;
  }


{ (null) java.lang.OutOfMemoryError
 at java.io.OutputStreamWriter.<init>(Compiled Code)
 at java.io.OutputStreamWriter.<init>(Compiled Code)
 at java.io.PrintStream.<init>(Compiled Code)
 at java.io.PrintStream.<init>(Compiled Code)
 at sun.net.www.http.HttpClient.openServer(Compiled Code)
 at sun.net.www.http.HttpClient.openServer(Compiled Code)
 at sun.net.www.http.HttpClient.<init>(Compiled Code)
 at sun.net.www.http.HttpClient.<init>(Compiled Code)
 at sun.net.www.http.HttpClient.New(Compiled Code)
 at sun.net.www.protocol.http.HttpURLConnection.connect(Compiled Code)
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Compiled
Code)
 at com.dbnet.common.email.EmailServlet.isURLValid(Compiled Code)
 at com.dbnet.common.email.EmailServlet.doPost(Compiled Code)
 at javax.servlet.http.HttpServlet.service(Compiled Code)
 at javax.servlet.http.HttpServlet.service(Compiled Code)
 at com.livesoftware.jrun.JRun.runServlet(Compiled Code)
 at com.livesoftware.jrun.JRunGeneric.handleConnection(Compiled Code)
 at com.livesoftware.jrun.JRunGeneric.handleProxyConnection(Compiled
Code)
 at
com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(Compiled
Code)
 at com.livesoftware.jrun.service.ThreadConfigHandler.run(Compiled Code)

 at java.lang.Thread.run(Compiled Code)
 }

___________________________________________________________________________
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