aspose file tools*
The moose likes JSP and the fly likes jsp:getProperty / expression returns null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:getProperty / expression returns null" Watch "jsp:getProperty / expression returns null" New topic
Author

jsp:getProperty / expression returns null

karthik chellappan
Ranch Hand

Joined: Jul 01, 2007
Posts: 31
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.


karthik
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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

Joined: Jul 01, 2007
Posts: 31
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
jQuery in Action, 2nd edition
 
subject: jsp:getProperty / expression returns null