views:

24

answers:

1

I'm working with Direct Web Remoting (DWR) as part of a 'plain' dynamic Java project (hosted on a Tomcat 6.0 server with Java 6). I have a simple JSP page which interacts with session-level variables within my user's session. However, I also have a session-level object managed by DWR via the 'new' constructor.

Is it possible to, from within my JSP, retrieve and interact with the object managed by DWR? This isn't technically reverse AJAX, and I believe JSP pages normally fall outside the DWR thread.

A: 

It turns out that, rather simply, the objects are provided via the session variable available to the JSP page context. By calling session.getAttribute(...) on the appropriate object name, as dictated in javascript name of the class mapping in dwr.xml, I can grab the associated session-level instance of it.

NBJack
One small snag with this is that the session object isn't created until after there's a call to the object via DWR. I've read that a forced page-refresh can fix this, but it appears constructing the object when it isn't present and putting it into the session under the same name manually works fine. DWR seems to accept it as long as the name/type pair is expected.
NBJack