• 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:getProperty / expression returns null

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to do a simple example of UseBean Tag in JSP.

UserBean.java


firstAdditional.jsp:



secondAdditional.jsp:


thirdAdditional.jsp:


also tried using expression, which also returned null.


I'm not sure how to debug this. Please point out where i'm going wrong.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You appear to be missing a quote in your input field around the name attribute:


With regards to debugging, Put some extra statements on your JSP page to test certain values.
I would recommend checking
- the request parameter being passed in (is the form value being submitted)
- the value in the bean (is the value being passed into the bean)
- the sesion id (are we maintaining the session)


On page 2, this code will see that the parameter is passing through correctly
And then check if your bean is being populated.

On page 3, the parameter should be null, the bean username should be populated, and the sessionid should be the same as the previous one.



 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stefan.

Earlier i was getting 'The value for the useBean class attribute is invalid' error and on googling i got links which said that there should be a public default constructor without arguments in the java bean class. But for me issue was with class files not under WEB_INF directory.

Is it necessary that i include a public default constructor without arguments in the java bean class? As i see that above code runs fine without the constructor also.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

karthik chellappan wrote:issue was with class files not under WEB_INF directory.


WEB-INF, not WEB_INF.

Is it necessary that i include a public default constructor without arguments in the java bean class?


If there is no nullary constructor (one with no arguments), then it's not a bean, by definition.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic