Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieve the Value of a Bean Property in a Servlet

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my servlet, I delegate a method

to a business logic class EditorService.java. The findEditorData( username ) searches the database and populates the properties of a JavaBean (EditorBean.java)

I got a NULL when tried to retrieve the value of one of the Bean's property in this servlet:

But, it is not possible. Because I had no problem to wrap the EditorBean in a session object:

and then passed the session object to a JSP, got the property from the session object, printed out the value of this property, which was not a null.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the thing to do is to look in your work folder (eg tomcat/work) and find the code for getting the bean in a servlet from the JSP you wrote that accessed it
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

for getting the bean in a servlet from the JSP you wrote that accessed it.

In my servlet, I tried to get one of the properties of the bean - I got a null.
I am not trying to, and I do not want to, get the bean from the JSP. I simply tested to get one of the properties of the bean in a JSP - it was not a null.
[ December 06, 2003: Message edited by: JiaPei Jen ]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing the rest of your servlet code I can't be sure, but are you sure it's not a "scope" problem? Check that you don't have two variables called "editor" in your JSP, and that you have definately initialised the editor variable before you use it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic