users@jersey.java.net

Re: [Jersey] setting session attributes at resource startup

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 01 Jul 2008 17:44:57 +0200

Arul Dhesiaseelan wrote:
> Something like shown below won't work even in 0.8?
>
> @Path("singleton")
> @Singleton
> public static class SingletonResource {
> @Context
> HttpServletRequest r;
>
> public SingletonResource(@Context HttpServletRequest r) {
> this.r = r;
> r.getSession().setAttribute("test", "true");
> }
>
> @ProduceMime("text/plain")
> @GET
> public String get() {
> //return r.getPathInfo();
> return (String)r.getAttribute("test");
> }
> }
>

The above functionality for constructor parameters on singletons is
supported in the latest build.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109