Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / October 2003

Tip: Looking for answers? Try searching our database.

Accessing JavaBeans from Servlets

Thread view: 
Matthias - 23 Oct 2003 18:10 GMT
I initialized a JavaBean at the startsite of my web application with
the scope "session" and set the initial values of the properties. All
the following JSP-sites of my application are working very well with
this JavaBean, but I'm using servlets too and need access to the
current values of my JavaBean. If I try to access it with

   javabean j = new javabean();

the engine is obviously creating a new instanz with empty (null)
properties. How can I access the JavaBean from my servlets?

Thanx

Matthias
John C. Bollinger - 23 Oct 2003 20:44 GMT
> I initialized a JavaBean at the startsite of my web application with
> the scope "session" and set the initial values of the properties. All
[quoted text clipped - 6 lines]
> the engine is obviously creating a new instanz with empty (null)
> properties. How can I access the JavaBean from my servlets?

When you create a bean in session scope via a <jsp:useBean> action,
behind the scenes the bean is stored as a session attribute with the
specified name.  From a servlet, then, you can obtain the relevant
session object from the request, and extract the bean you want via the
session's getAttribute method.

John Bollinger
jobollin@indiana.edu


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.