• 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

Retrieve the Value of a Bean Property in a Servlet

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Is that a spider in your hair? Here, threaten it with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic