testing URLs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stack
    New Member
    • Sep 2007
    • 40

    #1

    testing URLs

    Hi all,

    I'm trying to make a simple browser that will try to display web pages
    and will also check for user's mistakes such as omission of "http://" or
    "www". What I'm having difficulty with, is how to test if a page
    is downloaded (that is if the URL is correct) after "setPage" method is called.

    Would this be a proper way to do it?
    Code:
    if(editorPane.getPage().toString().equals(""))
    //then the URL is not working

    Thanks a lot
    stack
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by stack
    Hi all,

    I'm trying to make a simple browser that will try to display web pages
    and will also check for user's mistakes such as omission of "http://" or
    "www". What I'm having difficulty with, is how to test if a page
    is downloaded (that is if the URL is correct) after "setPage" method is called.

    Would this be a proper way to do it?
    Code:
    if(editorPane.getPage().toString().equals(""))
    //then the URL is not working

    Thanks a lot
    stack
    Form your code a URL is not valid only if it is the empty string.
    Is that how you want your URL checker to behave?

    Have a look at the specs for the URL class itself.

    Comment

    • stack
      New Member
      • Sep 2007
      • 40

      #3
      Originally posted by r035198x
      Form your code a URL is not valid only if it is the empty string.
      Is that how you want your URL checker to behave?

      Have a look at the specs for the URL class itself.
      Thank you for your reply.
      I want my URL checker to tell me if the URL attempted is valid or not. I read the URL class you suggested but I can't find any method suitable for that.
      Any more hints?

      Thanks again

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by stack
        Thank you for your reply.
        I want my URL checker to tell me if the URL attempted is valid or not. I read the URL class you suggested but I can't find any method suitable for that.
        Any more hints?

        Thanks again
        Don't just read it to get a ready made method to solve the problem.
        For example when you read the specs for that class, when does it say a MalformedURLExc eption is thrown?

        Comment

        • stack
          New Member
          • Sep 2007
          • 40

          #5
          Originally posted by r035198x
          Don't just read it to get a ready made method to solve the problem.
          For example when you read the specs for that class, when does it say a MalformedURLExc eption is thrown?

          Ok, got it.

          Thanks a lot

          Comment

          Working...