NullPointer Exception - getAttribute

Discussion in 'Java' started by VitaminB, Apr 26, 2006.

  1. VitaminB

    VitaminB Guest

    Hello,

    I want to parse a HTML document to get all URLs of the frames in a
    frameset. I get a "NullPointer Exception" in String s =
    (String)attSet.getAttribute(HTML.Attribute.SRC);


    Thanks a lot for you help.
    Regards, Marcus

    ##################
    Exception
    ##################
    http://dev0004/Test/HET/PerformanceTestDB.nsf/Main?OpenFrameset
    java.lang.NullPointerException
    at Stress.urlRequest(Stress.java:82)
    at Stress.run(Stress.java:40)


    ##################
    Java Code:
    ##################


    URL urlobj = new URL(str);


    HttpURLConnection uc = null;
    uc = (HttpURLConnection)urlobj.openConnection();
    uc.setUseCaches(false);
    DataInputStream is = new DataInputStream(uc.getInputStream());


    HTMLEditorKit hKit = new HTMLEditorKit();
    HTMLDocument hDoc = new HTMLDocument();
    hKit.read(is, hDoc, 0);
    HTMLDocument.Iterator it = hDoc.getIterator(HTML.Tag.FRAME);


    AttributeSet attSet = it.getAttributes();
    String s = (String)attSet.getAttribute(HTML.Attribute.SRC);
    System.out.println(s);


    ##################
    Beispiel HTML-Seite:
    ##################


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
    <html>
    <head>


    <script language="JavaScript" type="text/javascript">
    <!--
    self._domino_name = "_Main";
    // -->
    </script>
    </head>


    <frameset cols="45%,55%">


    <frame
    src="/Test/HET/PerformanceTestDB.nsf/ContentDeliveryMeasurement?OpenForm">



    <frameset rows="1*,1*">


    <frame src="/Test/HET/PerformanceTestDB.nsf/DocsInserted?OpenView">


    <frame name="docPreviewFrame"
    src="/Test/HET/PerformanceTestDB.nsf/select?OpenForm">
    </frameset>
    </frameset>
    </html>
     
    VitaminB, Apr 26, 2006
    #1
    1. Advertising

  2. VitaminB

    Oliver Wong Guest

    "VitaminB" <> wrote in message
    news:...
    >
    > I want to parse a HTML document to get all URLs of the frames in a
    > frameset. I get a "NullPointer Exception" in String s =
    > (String)attSet.getAttribute(HTML.Attribute.SRC);


    Did you check that attSet is not null?

    - Oliver
     
    Oliver Wong, Apr 26, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jens Mueller
    Replies:
    0
    Views:
    607
    Jens Mueller
    Apr 12, 2005
  2. FX
    Replies:
    3
    Views:
    304
    Thomas Fritsch
    Sep 12, 2006
  3. Replies:
    2
    Views:
    552
  4. =?Utf-8?B?U21pdGE=?=

    Listbox inside a Gridview gives a nullpointer exception

    =?Utf-8?B?U21pdGE=?=, May 30, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    342
    Alexey Smirnov
    May 31, 2007
  5. Chen
    Replies:
    1
    Views:
    859
    Stanimir Stamenkov
    Oct 8, 2008
Loading...

Share This Page