tags:

views:

156

answers:

2

Hello

Iam new to struts tag libraries. I want to generate an anchor to define a hyperlink destination inside the same document. my code is like this:

<html:link anchor="abc" >
            This is to test anchors
</html:link> 

...Some other tags here

<html:link linkName = "abc"  >
           Anchor
</html:link>

The error Iam getting is "Cannot create rewrite URL: java.net.MalformedURLException: You must specify exactly one of "forward", "href", or "page"'

Can anybody tell me how to solve this? Thanks

A: 

as i understand struts and from apache

You must specify exactly one of the action attribute, the forward attribute, the href attribute, the linkName attribute, or the page attribute.

so in your first tag, i would guess that you would need to add an href tag and the anchor is added on to that. then your tag with linkname should work

that is

<html:link href="someurl" anchor="abc" >
            This is to test anchors
</html:link>
Kamal
But the hyperlink destination is in the same doccument. so do we still need to specify href?? In html equivalent <a> href = "#abc" we do not specify the url if it is in the same document.how to do it in struts?
daniel
You need to set the href because it's a prerequisite. (or at least one of the attributes specified above). so if it's on the same page, i guess you would set the href="#" and anchor="abc".
Kamal
A: 

I think href="#" never worked. My jsps are in WEB-INF/tiles/. In my case, I use Tiles to build my site layout, so header, navigation, footer, dynamic body all comes from the layout.jsp. I've one jsp file details.jsp, though it's plain html document, I've to use the layout.jsp to get the header, footer, left navigation and the detail.jsp has couple anchor link like this FAQs and it has to go the FAQ section of that document. So when I mouse over the faq link, it displays the url as webapp/WEB-INF/tiles/layout.jsp#faq. The url should supposed to be webapp/detail.do and whenever I click the anochor tag it should be webapp/detail.do#faq or webapp/detail.do#contactus etc without going through the ActionController eachtime I click the anchor tag. I'm looking for a solution. Thank you in advance! AK

askjeeves