| Author |
how to pass parameter in struts ?
|
harish pathak
Ranch Hand
Joined: Dec 17, 2005
Posts: 51
|
|
Hi All, Anybody please tell me how to pass parameter in struts as we pass parameter in jsp/servlet as ?name=name&sex=sex Thanks harish
|
 |
Rob Morning
Greenhorn
Joined: Jan 02, 2006
Posts: 4
|
|
Save it in the session usingsomething like session.setAttribute("USER",user); session.setAtttribute("SEX",sex); in your JSP .. Is that what you mean ?
|
 |
harish pathak
Ranch Hand
Joined: Dec 17, 2005
Posts: 51
|
|
no i mean like in our jsp we do like this so how we do in struts. <% String s =" harish"; %> <a href="/abc.jsp?name=<%=s%>">click here</a> How can we pass parameters in struts Thanks harish
|
 |
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
|
|
The equivalent of your example using struts tags would be: <bean:define id="userName" value="Harish"/> <a href='/abc.jsp?name=<bean:write name="userName" />'>click here</a> [ January 07, 2006: Message edited by: Merrill Higginson ]
|
Merrill
Consultant, Sima Solutions
|
 |
shahin Khan
Greenhorn
Joined: Mar 04, 2005
Posts: 17
|
|
|
You can pass it in the similar manner as you pass in jsp.Are you facing any problems with this if so plz let me know
|
 |
Thierry Collogne
Greenhorn
Joined: Oct 19, 2005
Posts: 16
|
|
If you pass your parameter like this You can use the following to retreive I hope this helps. Thierry
|
 |
Thierry Collogne
Greenhorn
Joined: Oct 19, 2005
Posts: 16
|
|
Sorry, little mistake is wrong. This needs to be The paramName is the value, as it is in the pagecontext, you want to pass and paramId is the name of the parameter.
|
 |
Vikrama Sanjeeva
Ranch Hand
Joined: Sep 02, 2001
Posts: 756
|
|
Hi, Make a FormBean (ActionForm) of the JSP from where you are passintg the value and declare getter/setter of the variable which is holding your value. For "?name=abc&sex=male" define a form bean which have getter/setter for name and sex variables. In the action, retrieved the values of name and sex using form's getter method. E.g: Hope it will helps. Bye, Viki.
|
Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining http://groups.yahoo.com/group/IBM340Exam/
|
 |
Yugesh Cc
Greenhorn
Joined: Jul 12, 2006
Posts: 1
|
|
Craeting the bean with setters and getters works fine , but if we use this approach only those value can be obtained which are there in form (e.g.text boxes etc).But what should i do if i want to pass some additional parameters thru that JSp page. I wish to use hidden variables for this but when i try to assign value to a hidden variable then it gives error as bellow "According to TLD, tag html:hidden must be empty, but is not" How can i use hidden variables in struts then
|
 |
Dom Lassy
Ranch Hand
Joined: May 05, 2006
Posts: 181
|
|
Originally posted by Yugesh Cc: I wish to use hidden variables for this but when i try to assign value to a hidden variable then it gives error as bellow "According to TLD, tag html:hidden must be empty, but is not"
Please post your html:hidden code block. Read this first and see if it helps: http://struts.apache.org/1.2.7/userGuide/struts-html.html#hidden
|
 |
netto gaurav
Greenhorn
Joined: Jan 29, 2008
Posts: 7
|
|
hi i also have the same problem i have an list of records on one column i have the edit image which when clicked opens the record for editing now I'm not getting how to pass the value to the action class and how to get the values of the telephone at the action the code is below: please reply its urgent
|
 |
Pawan Singh
Greenhorn
Joined: Jun 05, 2012
Posts: 9
|
|
I found the solution by my own
you just have to set the object in pagecontext.setattribute(String arg0, Object arg1)
then <html:link action="......" paramid="XXX" paramName="String arg0"/>
you can retrieve this parameter in your action class as :
request.getParameter("XXX"/paramid);
here in code view:
<%String mail=sf.getEmailid();
pageContext.setAttribute("emailid",mail);%>
<html:link action="/information" onfocus="focus()" paramId="mailid" paramName="emailid" scope="request"><font color="#00FF00">
<%= sf.getEmailid() %></font></html:link></td>
<%}%>
here sf.getEmailid() is a String type Object which i have to pass as a parameter from a jsp to action class in link form.
hope you like this , and definetly it will work.
|
 |
 |
|
|
subject: how to pass parameter in struts ?
|
|
|