Home » Eclipse Projects » Remote Application Platform (RAP) » Remember Data on page reload
Remember Data on page reload [message #137857] |
Thu, 25 June 2009 07:24  |
Eclipse User |
|
|
|
Hi,
How do I remember informations when the user reloads the page in the
browser.
Say I open my application with an URL like this:
-------8<-------
http://127.0.0.1:55350/rap?startup=bizerbawb&username=bl abla&password=bloblo
-------8<-------
In reality these 2 parameters are passed as post parameters :-) Now my
user wants to switch the language which I implemented by simply
reloading the page and like this:
-------8<-------
parent.window.location.href=' http://127.0.0.1:55350/rap?startup=bizerbawb&language=de _DE'
-------8<-------
Naturally I can't pass the username and password now because of security
reasons. In standard web-applications I'd restore those informations in
the HttpSession and that's what I thought would be possible also.
So I tried:
- RWT.getSession()
- RWT.getSessionStore()
- RWT.getRequest().getSession()
but it looks like those sessions are clear when ever I reload the page.
So I'm a bit stuck now because my standard Servlet-Knowlege doesn't seem
to work.
Tom
|
|
| | |
Re: Remember Data on page reload [message #137904 is a reply to message #137883] |
Thu, 25 June 2009 08:49   |
Eclipse User |
|
|
|
Originally posted by: benjamin.wolff.web.de
hm, that's odd, since i'm using this mechanism to store login information throughout session.
for example, when logging in i do:
RWT.getSettingStore().setAttribute("username", "bla");
RWT.getSettingStore().setAttribute("password", "blabla");
in a new session i do:
String username = (String) RWT.getSettingStore().getAttribute("username");
String password = (String) RWT.getSettingStore().getAttribute("password");
and then i get the values that have been stored in a previous session.
please distiguish between the RWT.getSETTINGStore() and RWT.getSESSIONStore()...
HTH,
-ben
Tom Schindl schrieb:
> Hi,
>
> I tried it already and it is cleared when I reload the page!
>
> Tom
>
> Ben W. schrieb:
>> take a look at RWT.getSettingStore() and ISettingStore doc?! afaik this
>> mechanism works with cookies, maybe this is a point for further
>> investigations?!
>>
>> HTH,
>> -ben
>>
>>
>>
>> Tom Schindl schrieb:
>>> Hi,
>>>
>>> How do I remember informations when the user reloads the page in the
>>> browser.
>>>
>>> Say I open my application with an URL like this:
>>> -------8<-------
>>> http://127.0.0.1:55350/rap?startup=bizerbawb&username=bl abla&password=bloblo
>>>
>>> -------8<-------
>>>
>>> In reality these 2 parameters are passed as post parameters :-) Now my
>>> user wants to switch the language which I implemented by simply
>>> reloading the page and like this:
>>>
>>> -------8<-------
>>> parent.window.location.href=' http://127.0.0.1:55350/rap?startup=bizerbawb&language=de _DE'
>>>
>>> -------8<-------
>>>
>>> Naturally I can't pass the username and password now because of security
>>> reasons. In standard web-applications I'd restore those informations in
>>> the HttpSession and that's what I thought would be possible also.
>>>
>>> So I tried:
>>> - RWT.getSession()
>>> - RWT.getSessionStore()
>>> - RWT.getRequest().getSession()
>>>
>>> but it looks like those sessions are clear when ever I reload the page.
>>>
>>> So I'm a bit stuck now because my standard Servlet-Knowlege doesn't seem
>>> to work.
>>>
>>> Tom
|
|
|
Re: Remember Data on page reload [message #137916 is a reply to message #137904] |
Thu, 25 June 2009 09:24   |
Eclipse User |
|
|
|
Hi,
You are sooooo right - I had a typo and really used
RWT.getSESSIONStore() :-)
Tom
Ben W. schrieb:
> hm, that's odd, since i'm using this mechanism to store login
> information throughout session.
>
> for example, when logging in i do:
>
> RWT.getSettingStore().setAttribute("username", "bla");
> RWT.getSettingStore().setAttribute("password", "blabla");
>
>
> in a new session i do:
>
> String username = (String) RWT.getSettingStore().getAttribute("username");
> String password = (String) RWT.getSettingStore().getAttribute("password");
>
> and then i get the values that have been stored in a previous session.
>
>
> please distiguish between the RWT.getSETTINGStore() and
> RWT.getSESSIONStore()...
>
>
> HTH,
> -ben
>
>
>
>
> Tom Schindl schrieb:
>> Hi,
>>
>> I tried it already and it is cleared when I reload the page!
>>
>> Tom
>>
>> Ben W. schrieb:
>>> take a look at RWT.getSettingStore() and ISettingStore doc?! afaik this
>>> mechanism works with cookies, maybe this is a point for further
>>> investigations?!
>>>
>>> HTH,
>>> -ben
>>>
>>>
>>>
>>> Tom Schindl schrieb:
>>>> Hi,
>>>>
>>>> How do I remember informations when the user reloads the page in the
>>>> browser.
>>>>
>>>> Say I open my application with an URL like this:
>>>> -------8<-------
>>>> http://127.0.0.1:55350/rap?startup=bizerbawb&username=bl abla&password=bloblo
>>>>
>>>>
>>>> -------8<-------
>>>>
>>>> In reality these 2 parameters are passed as post parameters :-) Now my
>>>> user wants to switch the language which I implemented by simply
>>>> reloading the page and like this:
>>>>
>>>> -------8<-------
>>>> parent.window.location.href=' http://127.0.0.1:55350/rap?startup=bizerbawb&language=de _DE'
>>>>
>>>>
>>>> -------8<-------
>>>>
>>>> Naturally I can't pass the username and password now because of
>>>> security
>>>> reasons. In standard web-applications I'd restore those informations in
>>>> the HttpSession and that's what I thought would be possible also.
>>>>
>>>> So I tried:
>>>> - RWT.getSession()
>>>> - RWT.getSessionStore()
>>>> - RWT.getRequest().getSession()
>>>>
>>>> but it looks like those sessions are clear when ever I reload the page.
>>>>
>>>> So I'm a bit stuck now because my standard Servlet-Knowlege doesn't
>>>> seem
>>>> to work.
>>>>
>>>> Tom
|
|
| |
Re: Remember Data on page reload [message #137950 is a reply to message #137916] |
Thu, 25 June 2009 09:28   |
Eclipse User |
|
|
|
Hi,
On a site note I think the approach from Rüdiger to use a static mao is
better because the setting store survives sessions (e.g. Browser
restart) which is a bad thing to happen!
Tom
Tom Schindl schrieb:
> Hi,
>
> You are sooooo right - I had a typo and really used
> RWT.getSESSIONStore() :-)
>
> Tom
>
> Ben W. schrieb:
>> hm, that's odd, since i'm using this mechanism to store login
>> information throughout session.
>>
>> for example, when logging in i do:
>>
>> RWT.getSettingStore().setAttribute("username", "bla");
>> RWT.getSettingStore().setAttribute("password", "blabla");
>>
>>
>> in a new session i do:
>>
>> String username = (String) RWT.getSettingStore().getAttribute("username");
>> String password = (String) RWT.getSettingStore().getAttribute("password");
>>
>> and then i get the values that have been stored in a previous session.
>>
>>
>> please distiguish between the RWT.getSETTINGStore() and
>> RWT.getSESSIONStore()...
>>
>>
>> HTH,
>> -ben
>>
>>
>>
>>
>> Tom Schindl schrieb:
>>> Hi,
>>>
>>> I tried it already and it is cleared when I reload the page!
>>>
>>> Tom
>>>
>>> Ben W. schrieb:
>>>> take a look at RWT.getSettingStore() and ISettingStore doc?! afaik this
>>>> mechanism works with cookies, maybe this is a point for further
>>>> investigations?!
>>>>
>>>> HTH,
>>>> -ben
>>>>
>>>>
>>>>
>>>> Tom Schindl schrieb:
>>>>> Hi,
>>>>>
>>>>> How do I remember informations when the user reloads the page in the
>>>>> browser.
>>>>>
>>>>> Say I open my application with an URL like this:
>>>>> -------8<-------
>>>>> http://127.0.0.1:55350/rap?startup=bizerbawb&username=bl abla&password=bloblo
>>>>>
>>>>>
>>>>> -------8<-------
>>>>>
>>>>> In reality these 2 parameters are passed as post parameters :-) Now my
>>>>> user wants to switch the language which I implemented by simply
>>>>> reloading the page and like this:
>>>>>
>>>>> -------8<-------
>>>>> parent.window.location.href=' http://127.0.0.1:55350/rap?startup=bizerbawb&language=de _DE'
>>>>>
>>>>>
>>>>> -------8<-------
>>>>>
>>>>> Naturally I can't pass the username and password now because of
>>>>> security
>>>>> reasons. In standard web-applications I'd restore those informations in
>>>>> the HttpSession and that's what I thought would be possible also.
>>>>>
>>>>> So I tried:
>>>>> - RWT.getSession()
>>>>> - RWT.getSessionStore()
>>>>> - RWT.getRequest().getSession()
>>>>>
>>>>> but it looks like those sessions are clear when ever I reload the page.
>>>>>
>>>>> So I'm a bit stuck now because my standard Servlet-Knowlege doesn't
>>>>> seem
>>>>> to work.
>>>>>
>>>>> Tom
|
|
| | | | |
Re: Remember Data on page reload [message #138134 is a reply to message #137990] |
Fri, 26 June 2009 06:40   |
Eclipse User |
|
|
|
Hi,
This works great. Now one final question and I'm totally happy. Do you
know if it possible to somehow modify the main-html page so that I can
add a hidden IFRAME where I redirect file downloads to?
Tom
Ben W. schrieb:
> hi,
>
> using servlets in conjunction with a RAP/server-side equinox application
> is as easy as can possibly be imagined :PP.
> just use the org.eclipse.equinox.http.registry.servlets extension point
> and point to the servlet class and fill in the other parameters.
> you can then use the servlets in an embedded jetty or deployed in a
> tomcat environmen.
>
>
> HTH,
> -ben
>
>
>
> Tom Schindl schrieb:
>> Hi Rüdiger,
>>
>> Works like a charme but I'm not sure how I should add a session listener
>> in context of an RAP-Application.
>>
>> Do you by chance have a pointer how I do that in an RAP-env? I also have
>> to register 2 more servlets in the Jetty (to produce PDF and CSV-Files).
>>
>> So the general question might be how to configure the underlying
>> Jetty-Instance through extension points.
>>
>> Tom
>>
>> Rüdiger Herrmann schrieb:
>>> Tom,
>>>
>>> currently all session attributes are removed from the HttpSession. The
>>> ISessionStore is itself an attribute taht is stored in the HttpSesion.
>>> If you feel that it is a general requirement to have sme attributes
>>> "survive" a session restart, please file an enhancement request.
>>>
>>> Meanwhile you could work around this by storing the user information in
>>> a static map. As a key you can use the session id (it doesn't change
>>> with a session restart).
>>> The first login would store user/password in the map under the session
>>> id. A "restart-request" would encounter that there is no user/password
>>> in the request parameters and consult the map.
>>> To save memory, remove the entry from the map when the session is
>>> invalidated.
>>>
>>> Another approach would be form based authentication. It should also
>>> work, thou I haven't tried it myself.
>>>
>>> HTH
>>> Rüdiger
>>>
>>>
>>> Tom Schindl wrote:
>>>> Hi,
>>>>
>>>> How do I remember informations when the user reloads the page in the
>>>> browser.
>>>>
>>>> Say I open my application with an URL like this:
>>>> -------8<-------
>>>> http://127.0.0.1:55350/rap?startup=bizerbawb&username=bl abla&password=bloblo
>>>>
>>>>
>>>> -------8<-------
>>>>
>>>> In reality these 2 parameters are passed as post parameters :-) Now my
>>>> user wants to switch the language which I implemented by simply
>>>> reloading the page and like this:
>>>>
>>>> -------8<-------
>>>> parent.window.location.href=' http://127.0.0.1:55350/rap?startup=bizerbawb&language=de _DE'
>>>>
>>>>
>>>> -------8<-------
>>>>
>>>> Naturally I can't pass the username and password now because of
>>>> security
>>>> reasons. In standard web-applications I'd restore those informations in
>>>> the HttpSession and that's what I thought would be possible also.
>>>>
>>>> So I tried:
>>>> - RWT.getSession()
>>>> - RWT.getSessionStore()
>>>> - RWT.getRequest().getSession()
>>>>
>>>> but it looks like those sessions are clear when ever I reload the page.
>>>>
>>>> So I'm a bit stuck now because my standard Servlet-Knowlege doesn't
>>>> seem
>>>> to work.
>>>>
>>>> Tom
|
|
|
Re: Remember Data on page reload [message #138158 is a reply to message #138134] |
Fri, 26 June 2009 07:22  |
Eclipse User |
|
|
|
Tom Schindl wrote:
> Hi,
>
> This works great. Now one final question and I'm totally happy. Do you
> know if it possible to somehow modify the main-html page so that I can
> add a hidden IFRAME where I redirect file downloads to?
You would need a "branding" that - among other things - allows you
to insert HTML snippets into the main page.
See here for the branding documentation:
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .rap.help/help/html/advanced/branding.html
The documentation of the body attribute might be a bit misleading.
You need to specify a file that contains an HTML snippets that goes
into the body element of the page.
>
> Tom
>
> Ben W. schrieb:
>> hi,
>>
>> using servlets in conjunction with a RAP/server-side equinox application
>> is as easy as can possibly be imagined :PP.
>> just use the org.eclipse.equinox.http.registry.servlets extension point
>> and point to the servlet class and fill in the other parameters.
>> you can then use the servlets in an embedded jetty or deployed in a
>> tomcat environmen.
>>
>>
>> HTH,
>> -ben
>>
>>
>>
>> Tom Schindl schrieb:
>>> Hi Rüdiger,
>>>
>>> Works like a charme but I'm not sure how I should add a session listener
>>> in context of an RAP-Application.
>>>
>>> Do you by chance have a pointer how I do that in an RAP-env? I also have
>>> to register 2 more servlets in the Jetty (to produce PDF and CSV-Files).
>>>
>>> So the general question might be how to configure the underlying
>>> Jetty-Instance through extension points.
>>>
>>> Tom
>>>
>>> Rüdiger Herrmann schrieb:
>>>> Tom,
>>>>
>>>> currently all session attributes are removed from the HttpSession. The
>>>> ISessionStore is itself an attribute taht is stored in the HttpSesion.
>>>> If you feel that it is a general requirement to have sme attributes
>>>> "survive" a session restart, please file an enhancement request.
>>>>
>>>> Meanwhile you could work around this by storing the user information in
>>>> a static map. As a key you can use the session id (it doesn't change
>>>> with a session restart).
>>>> The first login would store user/password in the map under the session
>>>> id. A "restart-request" would encounter that there is no user/password
>>>> in the request parameters and consult the map.
>>>> To save memory, remove the entry from the map when the session is
>>>> invalidated.
>>>>
>>>> Another approach would be form based authentication. It should also
>>>> work, thou I haven't tried it myself.
>>>>
>>>> HTH
>>>> Rüdiger
>>>>
>>>>
>>>> Tom Schindl wrote:
>>>>> Hi,
>>>>>
>>>>> How do I remember informations when the user reloads the page in the
>>>>> browser.
>>>>>
>>>>> Say I open my application with an URL like this:
>>>>> -------8<-------
>>>>> http://127.0.0.1:55350/rap?startup=bizerbawb&username=bl abla&password=bloblo
>>>>>
>>>>>
>>>>> -------8<-------
>>>>>
>>>>> In reality these 2 parameters are passed as post parameters :-) Now my
>>>>> user wants to switch the language which I implemented by simply
>>>>> reloading the page and like this:
>>>>>
>>>>> -------8<-------
>>>>> parent.window.location.href=' http://127.0.0.1:55350/rap?startup=bizerbawb&language=de _DE'
>>>>>
>>>>>
>>>>> -------8<-------
>>>>>
>>>>> Naturally I can't pass the username and password now because of
>>>>> security
>>>>> reasons. In standard web-applications I'd restore those informations in
>>>>> the HttpSession and that's what I thought would be possible also.
>>>>>
>>>>> So I tried:
>>>>> - RWT.getSession()
>>>>> - RWT.getSessionStore()
>>>>> - RWT.getRequest().getSession()
>>>>>
>>>>> but it looks like those sessions are clear when ever I reload the page.
>>>>>
>>>>> So I'm a bit stuck now because my standard Servlet-Knowlege doesn't
>>>>> seem
>>>>> to work.
>>>>>
>>>>> Tom
|
|
|
Goto Forum:
Current Time: Fri Jul 18 00:23:55 EDT 2025
Powered by FUDForum. Page generated in 0.12521 seconds
|