NullPointer Exception - getAttribute

V

VitaminB

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>
 
O

Oliver Wong

VitaminB said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top