• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp:useBean in Struts JSP

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi JavaRanchers
My problem is i m not getting how to use jsp:useBean in Struts Jsp.
i m setting javabean object in action in request and wanna use in jsp, ( reason i m goin away from Struts because i m finding a way to use 2 form for one action, and both this forms are interdependent )

here is the code whaich i wrote,

after running it i m getting [ ="<%contactDetails.getEmployerFname()%>" ] in text box.

JSP
-------------------------
<jsp:useBean id="contactDetails" scope="request" class="com.bitwise.smart.obj.ContactDetailsInfo" type="com.bitwise.smart.obj.ContactDetailsInfo">

<html:text property="txtEmployerFname"
value="<%contactDetails.getEmployerFname()%>" size="30" maxlength="30" tabindex="0"/>
</jsp:useBean>


Action
---------------------------------
contactDetailsInfo=employerbean.getContactDetails(sEmployerId,sContactId);
request.setAttribute("contactDetailsInfo", contactDetailsInfo);

EmployerBean
-------------
in this class

rs = stmt.executeQuery("SELECT CONTACTFNAME FROM EMPCONTACTINFO WHERE EMPLOYERID = '" + p_sEmployerId + "' AND CONTACTID = '" + p_sContactId +"'");
while(rs.next())
{
contactDetailsInfo = new ContactDetailsInfo();
contactDetailsInfo.setEmployerFname(rs.getString("CONTACTFNAME"));
}

ContactDetailsInfo
-----------------
it's java Bean

having property :

private String sEmployerFname= null;


Thanks

keviv
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is with tag nesting. If u have nested tags, then deeply nested tag should process first and then the sorrounding tags. In your case just use this line WITHOUT any use bean tags.
<html:text property="txtEmployerFname" name="contactDetails" value="employerFname" />
It will work.....
 
It's a tiny ad. At least, that's what she said.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic