This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes Error in simple bean and JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Error in simple bean and JSP" Watch "Error in simple bean and JSP" New topic
Author

Error in simple bean and JSP

Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

I have not understood beans properly and i am getting an error 500 : Cannot find any information on property 'name' in a bean of type 'cool.Person'.
Please help me to rectify this.

The jsp


The bean


web.xml


SCJP 6. Learning more now.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

On a quick inspection I can't see anything glaringly incorrect, but why are you using antiquated <jsp:getProperty> instead of the EL and JSTL?

What happens if you replace the getProperty tag with <c:out value="${dude.name}"/>?

(assuming you've enabled the JSTL)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

A minor doubt? I may be missing something glaringly obvious. But where are you setting the bean?


Learning and Learning!-- Java all the way!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

Vic Hood wrote:A minor doubt? I may be missing something glaringly obvious. But where are you setting the bean?

The <jsp:useBean> tag will create a bean in request scope if one with that name is not already resident.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

I agree Bear , but where are the initial values for the bean being set?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

They aren't, unless it's happening in a controller that we do not know about. The property may be null, but that will not result in the error that is being seen.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Oh okies, Thanks for the info
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Bear Bibeault wrote:
but why are you using antiquated <jsp:getProperty> instead of the EL and JSTL?

I did not know it was outdated. :confused: Why should i avoid using getProperty ?
I am using the head first book (1.5) and making working code out of the snippets in the book. Not reached the JSTL part yet.

Bear Bibeault wrote:
What happens if you replace the getProperty tag with <c:out value="${dude.name}"/>?
(assuming you've enabled the JSTL)


There is no error and i get a blank page. Why is that happening ? How to enable the JSTL ?

Thanks for telling me these new things. :)
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Please tell me how to make this work.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61448
    
  67

Instructions on setting up the JSTL can be found in the JspFaq.
 
Consider Paul's rocket mass heater.
 
subject: Error in simple bean and JSP