views:

1953

answers:

2

Hi,

If I view the HTML generated by one of my Jasper reports in IE7 I see the following:

<BR /><BR />
<A name="JR_PAGE_ANCHOR_0_1">
<TABLE style="WIDTH: 1000px" cellSpacing="0" cellPadding="0" bgColor="#ffffff" border="0">
<-- table body omitted -->
</TABLE>

The two BR tags are added via the JRHtmlExporterParameter.HTML_HEADER parameter. After these tags and before the beginning of the report table that there's an unclosed anchor tag that is generated by Jasper reports. The fact that this tag is not correctly closed is messing up the formatting of my report because IE is hyperlinking the entire report TABLE. I'm not actually using this anchor tag, so if I could prevent Jasper from generating it, that would solve my problem.

Incidentally, this problem only occurs in IE, in Firefox everything works fine because the anchor tag is properly closed.

Thanks in advance, Don

+1  A: 

That's odd code, the <br /> tags are XHTML-style, while the unclosed a tags are good old HTML, like the upper case tag names. If you serve such page with plain HTML header/content-type, perhaps IE will be happy.

When you write that Firefox closes the tag, I suppose you mean it correctly doesn't extend the hyperlink span over block tags. Note that FF's view source can display closing tags that are not there when you save the page to disk!

Frankly, I don't know if you can get rid of these anchors with some config. If nobody comes with a real solution, maybe you can download Jasper's source code and search JR_PAGE_ANCHOR in it, looking if the code generating it is conditionally driven.

Or, if you can, you can apply post-processing of the generated code.

PhiLho
As stated above, the BR tags are added by myself, whereas the A tag is added by Jasper. When I write that Firefox closes the tag what I mean is that it appears as a pair of matching open and closed tags when I view the generated source in Firebug.
Don
However, when I view the generated source in Web Developer (the IE equivalent of Firebug) it appears as shown above.
Don
Good you found a solution. For the record, Firebug shows a string version of the Dom, not the original source, so it is always well formed. And I understand better the uppercase tags if that's also a generated view.
PhiLho
+2  A: 

I took Phil's advice and dove into the Jasper source code. I've fixed the problem and submitted it to the project. Details of the cause and resolution are available here.

Don