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

html:link tag usage

John Holme
Ranch Hand

Joined: Oct 11, 2002
Posts: 54
I'm having a problem with the struts html:link tag which I can't unravel using the available documentation. My code snippet follow this explanation.
I have a bean named �photo� (an object of class �Photo�) in my jsp which is generated (presumably in page scope) by iterating through an ArrayList (�photoList�) using the logic:iterate tag. I can access this bean perfectly well using bean:write to write the �name� property of �photo�. However, when I try to access �photo� as the paramName in a single-parameter html:link tag, I get a null error in my jsp.
(With reference to the below code snippet, the paramProperty, �fileName� is a property of class Photo, which also includes the requisite getter and setter.)
Is there something wrong with the way I've written the html:link tag? Is there something wrong with placing �photo� into page scope using logic:iterate? (I've tried adding an extra bean efine for �photo�, but it doesn't seem to help.) What's going on here?
Thanks in advance for your suggestions,
John Holme
<logic:iterate name="photoList" id="photo">
<logic resent name="photo">
<html:linkparamName="photo"
paramId="fileName"
paramProperty="fileName"
page="photo.jsp"
target="main">
<bean:write name="photo" property="name"/><br>
</html:link>
</logic resent>
</logic:iterate>
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

You seem to be using the tag correctly, as far as I can tell. What happens, do you get an exception or is it just not generating the expected HTML? If you're getting an exception, post the first few lines of the stacktrace. Somebody might recognize something. If it's generating the HTML, post it and also what you were expecting.


Junilu - [How to Ask Questions] [How to Answer Questions]
John Holme
Ranch Hand

Joined: Oct 11, 2002
Posts: 54
Junilu, thanks for your reply. the stacktrace looks like this:
java.lang.NullPointerException at org.apache.struts.util.RequestUtils.pageURL(RequestUtils.java:1281) at org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:425) at org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:486) at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:350) at org.apache.jsp.toc_jsp._jspx_meth_html_link_0(toc_jsp.java:311) at org.apache.jsp.toc_jsp._jspx_meth_logic_present_1(toc_jsp.java:285) at org.apache.jsp.toc_jsp._jspService(toc_jsp.java:181) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530) at java.lang.Thread.run(Thread.java:536)
John Holme
Ranch Hand

Joined: Oct 11, 2002
Posts: 54
the line from my compiled jsp that throws the exception is (at toc_jsp.java:181):
if (_jspx_meth_logic_present_1(_jspx_th_logic_iterate_1, pageContext))
thanks again!
jh
John Holme
Ranch Hand

Joined: Oct 11, 2002
Posts: 54
when I remove the logic resent tags which appear to be the proximate cause of the exception, I receive instead a NullPointerException at the following line:
int _jspx_eval_html_link_0 = _jspx_th_html_link_0.doStartTag();
I guess learning to interpret these post-processed jsp tags is part of the learning curve; I haven't seen it discussed in anything I've read!
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4462
    
    6

OK, let's just eliminate things one at a time. First, the page attribute is context-relative, i.e. Struts automatically prepends the value of request.getContextPath() to the value of the page attribute. Try putting a slash ("/") in front of photo.jsp. If that doesn't work try putting the path to photo.jsp relative to your web application's context root. Come back if none of these things work.
E.g. if you access your application with a URL like

http://myserver.com/myapp/index.jsp
/myapp is your web application context and your application is probably deployed with the structure
../myapp/
../myapp/index.jsp
../myapp/photo.jsp
You need to write:
<html:link page="/photo.jsp" ...>
if photo.jsp is in a subdirectory such as
../myapp/jsps/photo.jsp
then you need to write:
<html:link page="/jsps/photo.jsp" ... >
[ March 31, 2003: Message edited by: Junilu Lacar ]
John Holme
Ranch Hand

Joined: Oct 11, 2002
Posts: 54
adding the "/" in front of "photo.jsp" did the trick. thanks for your help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:link tag usage