aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Unable to get property values using jsp:getProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Unable to get property values using jsp:getProperty" Watch "Unable to get property values using jsp:getProperty" New topic
Author

Unable to get property values using jsp:getProperty

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1529
    
  22

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

Joined: May 04, 2011
Posts: 144

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?


OCJP6, OCWCD5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to get property values using jsp:getProperty
 
Similar Threads
url not supported
JSP Bean,not able to work my first bean
exception handling
Problem in accessing the Map in c:forEach loop of JSTL
How to call a servlet from a html