I am trying to pass a parameter to action from my jsp using struts html link tag.
My struts-config.xml looks like this...
My action class is..
When I run the code, it says JSPG0218E: Error failed to locate setter method for attribute action in tag class org.apache.struts.taglib.html.LinkTag. Can you suggest what is wrong?
This is what I want to achieve: I want to call my InvoiceAction from the jsp to fetch the invoice info from DB and display it on another invoiceInfo.jsp page ( I would like the 2nd jsp on a different window like a popup or something )
Struts 1 is past end of life and is not supported.
That said, the error JSPG0218E is usually caused when a custom JSP tag references a property that the corresponding tag class does not have a setter for. Looking at the documentation for LinkTag, it does, in fact, have an "action" property.
What version of Struts 1 are you using?
I'm thinking the action attribute was added in a later version. I'm looking at the Struts 1.3 documentation and it does have the action attribute.
You could try upgrading Struts to a later version but that may have other side effects.
Another option is to use Java code in a scriptlet to construct your link, but that is considered "bad practice"
I agree. So, I switched to use href to accomplish it. This is how, I am doing it..
The onclick method is..
When I click on the link, it opens a new window and displays default error page. I believe the action is not called (the sysout I put in the action is not printed on the console). I'm not sure if my href approach is correct. Can you please suggest, how I should use it to call the action? Your help is much appreciated.
Does the popup window have an address bar? If not, turn it on and see what the URL is.
Look at the source code of the page in the browser. The generated "a" tag is probably different from the html:link tag.