File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Retrieve the Value of a Bean Property in a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Retrieve the Value of a Bean Property in a Servlet" Watch "Retrieve the Value of a Bean Property in a Servlet" New topic
Author

Retrieve the Value of a Bean Property in a Servlet

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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

Joined: Oct 04, 2003
Posts: 541
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


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309

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

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieve the Value of a Bean Property in a Servlet