aspose file tools*
The moose likes Struts and the fly likes Using bean:write with html:link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using bean:write with html:link" Watch "Using bean:write with html:link" New topic
Author

Using bean:write with html:link

SivaC Kumar
Greenhorn

Joined: Apr 18, 2006
Posts: 2
I am trying to send a value as a request variable to action class.But I am getting an exception.
My code is
<logic:iterate name="searchResultsForm" id="results" property="searchResults" type="com.ng.wft.wl.form.SearchUserForm" scope="session">
<tr>
<td><html:link action="/searchUser.do?user=<bean:write name="results" property="userId"/>&methodToCall='showDetails'"><bean:write name="results" property="userId" /></html:link></td>
<td><bean:write name="results" property="firstName" /></td>
<td><bean:write name="results" property="lastName" /></td>
</logic:iterate>

but it is giving a servlet Exception


[ServletException in:/content/jsp/admin/searchResults.jsp] /content/jsp/admin/searchResults.jsp(24,73) equal symbol expected'

this is code where the exception is coming

><html:link action="/searchUser.do?user=<bean:write name="results" property="userId"/>&methodToCall='showDetails'"><bean:write name="results" property="userId" /></html:link></td>


Can any one help me Plz!!!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can't use a <bean:write> tag inside an <html:link> tag. Struts doesn't support it.

The easiest way to fix this is to abandon use of <html:link> and just use the plain old html tags <a></a>. Then you will have no problem substituting parameters with <bean:write> tags.

The only advantage <html:link> has over the plain html tag is that it automatically does URL rewriting (Adding of the jsessionid to the URL so that sessions may be tracked even if the user has turned cookies off). If you're not using this function anyway, as most modern websites don't, you may as well use the html tag.

If you still want to use <html:link>, use the struts-el version of the html tags and use EL expressions instead of <bean:write> tags.
gao zhixin
Ranch Hand

Joined: Jan 18, 2006
Posts: 42
Some example using JSTL:

<a href="asdfasdf?action=${param.name}">aaaa</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using bean:write with html:link