« Return to Thread: Keep track of ScriptSessions for one browser

Re: Re: Keep track of ScriptSessions for one browser

by XMaNIaC :: Rate this Message:

Reply to Author | View in Thread

getScriptSessionById is a method of ServerContext. Here's the javadoc (from 3.0 HEAD)

getScriptSessionById

ScriptSession getScriptSessionById(java.lang.String sessionId)
You can request access to a specific ScriptSession if you know it's ID.

Take care with this method because it allows actions from one browser to affect another which could be a bad thing. It is certainly a VERY BAD idea to let session id's from one browser escape into another.

Consider that it is entirely possible that the ScriptSession may timeout while you are holding a reference to it.

Parameters:
sessionId - The script session ID to lookup
Returns:
The ScriptSession for the given ID, or null if it does not exist

On Thu, May 8, 2008 at 4:18 PM, Lance Java <lance.java@...> wrote:
One solution is to implement your own script session manager which intercepts script session creation, adding attributes to the script session based on the http session.

Later on, a reverse ajax thread can then differentiate between script sessions by their attributes.

<servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <display-name>DWR Servlet</display-name>
    <description>Direct Web Remoter Servlet</description>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
        <param-name>org.directwebremoting.extend.ScriptSessionManager</param-name>
        <param-value>foo.bar.MyScriptSessionManager</param-value>
    </init-param>
</servlet>

Not sure about looking up a script session by id... what's your use case?

Cheers,
Lance.

2008/5/8 Erlend Sobec <erlend.sobec@...>:

If this question has been asked so many times, I agree that it should definitely be in the FAQ.  However, since it isn't, perhaps you could tell me where I can find the answer rather than just tell me that it's been answered.  I did search and only found the solution for threads started by DWR, but in my case, the thread is NOT started by DWR so I can't just use WebContextFactory.get().getScriptSession().

Also, I asked where I can find info about the function getScriptSession(String id).  Has that also been answered?  If so where?

Thanks,

Erlend


On Wed, May 8, 2008 at 9:53 AM, Jose Noheda <jose.noheda@...> wrote:
> I think that we need a FAQ somewhere because this has been answered hundreds
> of times by now
>
> On Wed, May 7, 2008 at 10:39 PM, Erlend Sobec <erlend.sobec@...> wrote:
>
> > Is there a way to send back information to only one browser even though
> > multiple browsers are on the given page?
> >
> > My problem is that I have multiple users logged in accessing their data.
> > If there is an update for any given user, I don't want it to be sent to all
> > users currently logged in.
> >
> > I saw a post on how to deal with this if the thread is started by DWR, but
> > in my case it isn't. Also, in the javadoc there is mention of
> > getScriptSession(String id) but I can't find the method anywhere. Maybe I
> > could use this to determine which ScriptSession I need to send updates to.
> >
> > Thanks,
> >
> > Erlend
> >


 « Return to Thread: Keep track of ScriptSessions for one browser