File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Using bean:write with html:link

SivaC Kumar

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="" scope="session">
<td><html:link action="/<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>

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="/<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=${}">aaaa</a>
I agree. Here's the link:
subject: Using bean:write with html:link
It's not a secret anymore!