• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Unable to get property values using jsp:getProperty

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Input.jsp


ServletTwo.java


UsingBean.java


Input given to the form:
age 90
name mac

output
Person created by servlet mac 0 0

i am not able to retrieve the values of properties age empId of bean Person using getProperty in useBean.jsp
 
Creator of Enthuware JWS+ V6
Posts: 3346
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mohitkumar,

i am not able to retrieve the values of properties age empId of bean Person using getProperty in useBean.jsp



The empId is not set because the setProperty() (which is executed inside a jsp:useBean) is not executed as the bean already exists:

The age parameter doesn't surpass the RequestDispatcher.forward().
Just add the following line in your Servlet: mathur.setAge(new Integer(a));

Regards,
Frits
 
Ranch Hand
Posts: 144
Oracle Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest solution would be to set the values of age and empId in the doPost method. It seems weird to have request parameters from a form and ignore them. Is it safe to assume that the Person class has both a getAge() and getEmpId() methods?
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic