tags:

views:

231

answers:

1

hi want to access from bean object in jsp page .how to get that.pls help asap. 1)i have formbean class with customername,date,amount,rate etc with setter() and getter() for the field menmbers. 2) i have dataaccess class where i can get data for the bean calss property from database and set data to formbean class object like class formbean{ string amount;String rate; public void setAmount(String amount){this.amount=amouny}; String getAmount(){return amount;} etc.... }

class dao{ public Formbean fetchcust() { loan.setCloseDt11(rs.getString("CloseDt")); loan.setAmount11(rs.getString("Amount")); loan.setRate11(rs.getString("Rate")); return loan; } and returning this object. my question is how to access this object in jsp page

A: 

If your bean is an ActionForm (it’s not clear from your code if it is or not) then Struts exposes this into you JSP files and you have access to it from tags within <html:form>. You then just use the property attribute on the Struts tags and they will pick that up.

Also, you can have access to it by using JSTL or Struts bean tags since Struts exposes this in the request or session scope as a named attribute (the scope is specified in the struts-config.xml file in your action definition using the scope attribute and the exposed name is the name attribute of the same definition).

<action
      path="/actionName"
      type="some.package.ActionClass"
      name="yourForm"
      scope="request"
      ...
    >

If that form is a standard bean, not extending ActionForm than you must set this in the desired scope by hand using request.setAttribute(…) or session.setAttribute(…). Once in the JSP you can retrieve it using again JSTL or Struts bean tags.

dpb
my formbean exteds Action Form..my dao class returns the "object" of formbean class.in that dao class i set values to the setter() method of formbean class. like loan.setAmount(rs.getString(0)); return obj;in that case how to access that object in jsp page(the accessing jsp page is "popup window" if i click the button in baseform )
Manu