How to reliably share object between RAP and Servlets ? [message #546875] |
Wed, 14 July 2010 09:29  |
Eclipse User |
|
|
|
Hi all,
I include a servlet into my RAP application using
org.eclipse.equinox.http.registry.servlets ext. point.
When I need to inject some object references into this servlet from RAP
I use the following code :
ServletContext context = RWT.getRequest().getSession().getServletContext();
Object myObject = ...
context.setAttribute("mykey",myobject);
and from my servlet I use the following to get the value:
ServletContext context = request.getSession().getServletContext();
Object myObject = context.getAttribute("mykey");
But it seems that I can not reliably share object this way since
sometimes I get null reference in my servlet.
So what is the more reliable way to do this ?
Any help would be greatly appreciated.
Best Regards,
Setya
|
|
|
|
Re: How to reliably share object between RAP and Servlets ? [message #547229 is a reply to message #547199] |
Thu, 15 July 2010 23:17  |
Eclipse User |
|
|
|
Hi Ralf,
Thank you for your advice.
We use servlet because we need to accept data that comes from HTTP POST
sent by devices. When the data arrives the servlet will notify UI via
Display which is stored in servlet context.
We've never used IServiceHandler before but if it can do the job we
won't hesitate switching to it as it seems to be a lot easier.
Thanks & Regards,
Setya
> Hi Setya,
>
> did you consider implementing a custom IServiceHandler instead of using
> a servlet? Servlet handlers compare to servlets but can access
> application state. They can be registered programmatically or via
> extension point. See our FAQ for an example.
>
> Best regards, Ralf
>
> Setya wrote:
>> Hi all,
>>
>> I include a servlet into my RAP application using
>> org.eclipse.equinox.http.registry.servlets ext. point.
>>
>> When I need to inject some object references into this servlet from RAP
>> I use the following code :
>>
>> ServletContext context = RWT.getRequest().getSession().getServletContext();
>>
>> Object myObject = ...
>> context.setAttribute("mykey",myobject);
>>
>> and from my servlet I use the following to get the value:
>>
>> ServletContext context = request.getSession().getServletContext();
>> Object myObject = context.getAttribute("mykey");
>>
>> But it seems that I can not reliably share object this way since
>> sometimes I get null reference in my servlet.
>>
>> So what is the more reliable way to do this ?
>>
>> Any help would be greatly appreciated.
>>
>>
>> Best Regards,
>>
>> Setya
|
|
|
Powered by
FUDForum. Page generated in 0.03078 seconds