| Author |
Using both struts html:link and bean:write error
|
Yashnoo lyo
Ranch Hand
Joined: Feb 17, 2003
Posts: 152
|
|
Hi everyone: I write a struts app and have a problem.I use the html:link and bean:write TAG together.I want to use them display topic and add a hyperlink in these topic. Code is: <td><a href="/viewtopic.do?id=<bean:write name="love" property="id"/>"><bean:write name="love" property="title"/> The topic can display property.When I move mouse to the topic the statusbar disply:"http://localhost:3030/viewtopic.do?id=8" But when I click the hyperlink Tomcat report error: ////////////////////////////////////////////////////////// HTTP Status 400 - Invalid path /viewtopic was requested -------------------------------------------------------------------------------- type Status report message Invalid path /viewtopic was requested description The request sent by the client was syntactically incorrect (Invalid path /viewtopic was requested). /////////////////////////////////////////////////////////////////////// But I add the forward in my struts-config.xml.This: /////////////////////struts-config.xml////////////////////////////// ................................................ <forward name="viewtopic" path="/viewtopic.do"/> .......................................... <action path="/viewtopic" type="/viewtopic" actionClass="lyo.hotmail.bbs.Viewtopic"> <forward name="success" path="/jsp/viewtopic.jsp"/> </action> Why this? Do I mistake using Tag? :roll:
|
When I face C# and Java I choose Java.
|
 |
Bernardus Irmanto
Greenhorn
Joined: Oct 03, 2003
Posts: 23
|
|
Hi again.. try to use the domain-relative instead of module-relative path. for ex: instead of using "/viewTopic.do"..use something like "/loveForum/[module]/viewTopic.do" where the loveForum is your application context. U might also add the module (but you must reflect it in your struts config) rgds beN
|
 |
Yashnoo lyo
Ranch Hand
Joined: Feb 17, 2003
Posts: 152
|
|
Hi It also can't work.Error is: HTTP Status 400 - Invalid path /jsp/viewtopic was requested -------------------------------------------------------------------------------- type Status report message Invalid path /jsp/viewtopic was requested description The request sent by the client was syntactically incorrect (Invalid path /jsp/viewtopic was requested). I try to use the html:link tag : <html:link action="viewtopic.do?id=<bean:write name="love" property="id"/>"><bean:write name="love" property="title"/><html:link> The action viewtopic is in my struts-config.xml: //////////////////////////////////////////////////////////////////// <action path="/viewtopic" type="lyo.hotmail.bbs.Viewtopic" input="missfile.jsp"> <forward name="success" path="/jsp/viewtopic.jsp"/> </action> But it still can't work.Tomcat report error: org.apache.jasper.JasperException: /jsp/loveforum.jsp(29,61) equal symbol expected What it's mean? :roll:
|
 |
Bernardus Irmanto
Greenhorn
Joined: Oct 03, 2003
Posts: 23
|
|
Refering back to your first post, You have the following tag.. <a href="/viewtopic.do?id=<bean:write name="love" property="id"/>"> try to use <a href="[app_context]/viewtopic.do?id=<bean:write name="love" property="id"/>"> instead. I had similar problem sometimes ago. It worked well when I change the "module-relative" path in the href attribute to "domain-relative" path
|
 |
lyo Yashnoo
Ranch Hand
Joined: Sep 15, 2003
Posts: 50
|
|
Hi I try it but it can't work also.I am using Tomcat4.1.18.My web app's context path is "/myweb". After I change it to href="myweb/jsp/viewtopic.do?id=<bean:write ... ...", I move the mouse to the hyperlink,then the statusbar display "http://localhost:3030/myweb/jsp/myweb/jsp/viewtopic.do?id=4". When I click it Tomcat remain report the last error: HTTP Status 400 - Invalid path /jsp/myweb/jsp/viewtopic was requested -------------------------------------------------------------------------------- type Status report message Invalid path /jsp/myweb/jsp/viewtopic was requested description The request sent by the client was syntactically incorrect (Invalid path /jsp/myweb/jsp/viewtopic was requested). //////////////////////////////////////////////////////////////////// I am also change to href="/myweb/jsp/viewtopic.do?id=<bean... ..." Statusbar display :"http://localhost:3030/myweb/jsp/viewtopic.do?id=4" But it can't work too.error is: /////////////////////////////////////////////////////////// HTTP Status 400 - Invalid path /viewtopic was requested -------------------------------------------------------------------------------- type Status report message Invalid path /viewtopic was requested description The request sent by the client was syntactically incorrect (Invalid path /viewtopic was requested).In Tomcat console: /////////////////////////////////////////////////////////////////////// 2003-10-7 19:08:18 org.apache.struts.action.RequestProcessor processMapping server: Invalid path /viewtopic was requested :roll: So I think the html tag href can't be used with the struts TAG.Now I am thinking that I will use the "<html:link action paramId .. paramName ..>" Tag. The problem now is after I change the code to <html:link action="/viewtopic.do" paramName="lovebean" paramProperty="id" paramId="id"><bean:write name="love" property="title"/></html:link> I add the article data to arraylist ,later add the arraylist to request.setAttribute("lovetable",listdata); jsp code is: //////////////////////////////////////////////////// <logic:iterate id="love" name="lovetable"> <td><bean:write name="love" property="id"/></td> <td><html:link action="viewtopic.do" paramName="lovetable" paramProperty="id" paramId=""><bean:write name="love" property="title"/></html:link></td> <td><bean:write name="love" property="name"/></td> <td><bean:write name="love" property="time"/></td> </tr> </logic:iterate> Report error is: org.apache.jasper.JasperException: No getter method for property id of bean lovetable at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) //////////////////////////////////////////////////////// The lovetable is list and it don't have getter or setter indeed.whether I take a mistake while using the tag <html:link action=...>?HOw to use it?
|
 |
lyo Yashnoo
Ranch Hand
Joined: Sep 15, 2003
Posts: 50
|
|
Hi I use bean efine Tag successful and it can work property. my code is: <logic:iterate id="love" name="lovetable"> <bean efine id="idbean" name="love"/> <% String color=(i%2==0)?"white":"#CCC000"; %> <tr bgcolor="<%=color%>"> <td><bean:write name="love" property="id"/></td> <td><html:link forward="viewtopic" paramId="id" paramName="idbean" paramProperty="id"><bean:write name="love" property="title"/></html:link></td> <td><bean:write name="love" property="name"/></td> <td><bean:write name="love" property="time"/></td> </tr> <% i++; %> </logic:iterate> Thks for your help
|
 |
lyo Yashnoo
Ranch Hand
Joined: Sep 15, 2003
Posts: 50
|
|
|
sorry I forget to forbidden express symbol
|
 |
niranjan smith
Greenhorn
Joined: Sep 05, 2008
Posts: 4
|
|
Use this it will solve your problem.
">text
Thanks,
niranjan
|
 |
niranjan smith
Greenhorn
Joined: Sep 05, 2008
Posts: 4
|
|
Use this it will solve your problem.
">text
Thanks,
niranjan
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
lyo Yashnoo please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: Using both struts html:link and bean:write error
|
|
|