I am facing a problem with displaying the <html:link> tag in jsp. This is my jsp code:
<-- Taglib libraries defined here-->
<logic resent name="searchForm" property="results"> <%String xmldata=(String)request.getSession().getAttribute("xmlData"); %> <%=xmldata %> </logic resent> This shows a html data sent from the Action class assigned to the variable �xmldata�.
In my Action class I do something like this (for testing): public class searchaAction extends....{
xmldata=�<html:link action=\"TopicList.do?topic=VBR\" styleId=\"vmgmt-leftmenuHREF\" title=\"\" target=\"basefrm\"> this is a link</html:link>�; request.getSession().setAttribute("xmlData", data);
....} The issue is that the link is not shown in the main pane(only the text "this is a link" is shown as plain text). However, the following code works fine:
public class searchaAction extends....{ xmldata=�<a href=�abc.html�>this is a link</a>�;
Is there any special way to handle tags like �<html:Link>� when passed to the jsp as a html string, from action class?
Any pointer regarding this would really be much appreciated;
Thanks & regards, Sumita
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
posted
0
In order to understand why this won't work, let's review the JSP life cycle:
The JSP file is read by the JSP processor
Custom tags such as struts tags are interpreted and all JSP tags are converted to Java source code and compiled
The compiled code is executed. It is only at this point that your scriptlet actually executes and places the <html:link> tag in the output data stream along with the other html code.
So what's wrong with this picture? It's too late to put a Struts tag in the output stream. The custom tags were already interpreted much earlier in the life cycle. Solution: use a plain HTML <a> tag here, rather than a Struts html:link tag.