This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts 1.3 how to send link tag name to action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.3 how to send link tag name to action class" Watch "Struts 1.3 how to send link tag name to action class" New topic
Author

Struts 1.3 how to send link tag name to action class

venkat penmatsa
Greenhorn

Joined: Jul 23, 2011
Posts: 17
Hi All,

In Struts 1.3 by using link tag i want to send a value associated with the link clicked to the action class, consider a menu if i am clicking on a particular menu name then that name should be send to the action class.

please help me in resolving my issue.



Thanks in Advance,
venkat.
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Venkat,

You can make link as you make in jsp like test.action?menuname=xyz and get the menuname in the action.

Hope this will works for you.
Regards
Jatan
venkat penmatsa
Greenhorn

Joined: Jul 23, 2011
Posts: 17
jatan bhavsar wrote:Hi Venkat,

You can make link as you make in jsp like test.action?menuname=xyz and get the menuname in the action.

Hope this will works for you.
Regards
Jatan



Hi Jatan,

Thanks for your replay , I tried with same code but its not working, getting null value, please check and correct my code.

JSP code
<html:link action="/sample" property="xyz" >Register</html:link>

Struts-config.xml

<action path="/sample" name="SampleForm" validate="true" input="/Sample.jsp" type="com.Action.SampleAction">
<forward name="success" path="/CustomerTable.jsp" />
</action>

Form class
public class SampleForm extends ActionForm {

public String name;
public String xyz;

public String getXyz() {
return xyz;
}

public void setXyz(String xyz) {
this.xyz = xyz;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}


Action class

public class SampleAction extends Action{

public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

SampleForm c=(SampleForm)form;
String a = c.getName();
String b=c.getXyz();
System.out.println("******* Link Name *******"+a);
System.out.println("******* Link Name *******"+b);
return mapping.findForward("success");
}

}





 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Struts 1.3 how to send link tag name to action class
 
Similar Threads
what's wrong with this simple code
Struts menu jsp having problems if being processed after struts action
S2: autocompleter - how to populate a list based on user's input?
help on struts-config.xml execution
JSP - How to get the current URL?