Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reuse value from <bean:write> tag

Status
Not open for further replies.

DB2Problem

Programmer
Oct 17, 2002
53
0
0
US
How can i get the value from <bean:write> tag.

I have this bean write tag that gives me the value. I can see that coming up on the JSP page

I need to use this value in other parts of JSP page using something like

<% =country %>/imgs/help.jpg

My bean tag is something like

<bean:write property="country" name="CountryForm" />

Now i see the bean tag returing me USA. I need to use the value for further processing.

I don't want to use this at every place but wants to capture the value in another variable and use that variable

everywhere

How can i do this

Thanks for your help
 
I am havin same problem ,please let me know if you have found some answer..

I used
<bean:write name="itemlist" property="mcSerialId" />

</td><td>

SUCCEDED in retreiving iterated rows using List ,problem is with each row retrieved there is an associated submit button,

To make my life much more didfficult on clicking the submit of each row ,i must fetch data and forward it to another jsp..

Let me know how to use the value retrieved or property from each row in bean:write so that i can do something..
 
Hi,

You can use <bean:define /> tag to store the value into a variable and can use is multipule times with in the same page

ex: Java Bean
Code:
package view.test.bean;

public class TestBean 
{
  private String firstName = "";
  
  public TestBean()
  {
   this.firstName = "Its me";
  }

  public void setFirstName(String firstName)
  {
    this.firstName = firstName;
  }

  public String getFirstName()
  {
    return firstName;
  }
 
}

jsp code is like this

Code:
<jsp:useBean id="testBean" class="view.test.bean.TestBean" scope="page"/>
<bean:define name="testBean" id="firstName" property="firstName"/>
  <%=firstName%>

Hope this will help you...

Cheers
Venu
 
That works Venu, but then I get an undefined error when I try to use the same variable as parameter in one of the constructor call to java

something like

<%
Country usacountry = new Country (country);
%>

Now as long as i keep using this variable something like <%= country %> it displays value (USA) but when I try to use in Constructor it treats it as undefined - WHY ?? AND WHAT SHOULD I DO TO PASS IT PROPERLY
 
Hi,

What's the type of parameter is the java class constructor expecting is it an Object or String ? Coz contry is of type Object not String may be that is causing the problem.

Try some thing like this
Code:
<%
Country usacountry = new Country (country.toString());
%>

Cheers
Venu
 
Get that value using <bean:define id="somevalue" property="your value" name="formBean" />
and use that id variable where ever you want
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top