File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to get property values using jsp:getProperty

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • 0
  • 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
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2168
57
Android Chrome Eclipse IDE
  • 0
  • 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
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • 0
  • 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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic