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 / General / March 2006

Tip: Looking for answers? Try searching our database.

Setting and getting global attributes in servlets

Thread view: 
Bruce Lee - 05 Mar 2006 14:55 GMT
If I start up a Jetty web application and set an attribute to the
HttpContext like so

server.getContext("/").setAttribute("objectname",obj);

How do I now get this attribute from a servlet?

Thanks
Ed - 05 Mar 2006 15:32 GMT
> If I start up a Jetty web application and set an attribute to the
> HttpContext like so
[quoted text clipped - 4 lines]
>
> Thanks

Haven't used Jetty meself, but for plain-ol' servlets it's:
    HttpSession playerSession = httpServletRequest.getSession();
    playerSession.setAttribute("objectname", obj);

       And on the other side:
    HttpSession playerSession = httpServletRequest.getSession();
    Object obj = playerSession.getAttribute("objectname");

If Jetty offers the setAttribute() of the basic servlet but not the
getAttribute() then I'm sure there's a good reason for it ...

.ed

--
www.EdmundKirwan.com - Home of The Fractal Class Composition
Bruce Lee - 05 Mar 2006 15:48 GMT
> > If I start up a Jetty web application and set an attribute to the
> > HttpContext like so
[quoted text clipped - 20 lines]
> --
> www.EdmundKirwan.com - Home of The Fractal Class Composition

thanks for the reply. I'm looking at invoking an object at the top of the
server app and passing it down to the servlet level though. That'll work ok
for session but i want a permanent object I can control from the top.


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.