how to use a href in struts JSP?

Ted Husted

The html:link tag is designed so that you can do that without resorting to scriptlets. Try:
<html:link page="/callfile.do?action=w" paramName="bean" paramProperty="FILENAME" paramId="filename"/>

(Though, you may have problems unless the accessor is named getFilename, per the conventions.)

{soapbox}

Personally, I discourage use of the page form of html:link, and always use global forwards instead. This way all the entry points to your application are documented, and you don't have to expose API features like "action=w" in the JSP. You can give the action=w forward a logical name, and use that instead.

In struts-config:
<forward="callW" path="/callfile.do?action=w"/>
In your JSP:
<html:link forward="callW paramName="bean" paramId="filename"/>

In my own applications, the only place I expose the name of another Action is in the html:form tags (and I'm working on that;-)

{/soapbox}

HTH - Ted

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact