|
Re: Client-side javascript error on session timout [message #897437 is a reply to message #897312] |
Tue, 24 July 2012 03:11   |
Eclipse User |
|
|
|
Wouter,
there is no workaround that I'm aware of to prevent the client from
attempting to parse the HTML response (and failing as you described).
For now, you'd have to patch RWT with changes to the client code that
detect the session-expiry response.
However RAP should support such use cases. I could think of different
approaches:
* the client might just replace the current document with the content it
receives if the content is in an unexpected format.
* if the server sends redirect information in the HTTP header (HTTP
3xx), the client could issue a GET request to the redirect-URL
* make the client side response-handler pluggable so that applications
can contribute specialized handler and the current handler would just be
a default/fallback handler
* ...
Would you mind to open an enhancement request to capture the use case
and discuss solutions?
Regards,
Rüdiger
On 23.07.2012 16:54, Wouter R wrote:
> We run RAP as a webapp on a tomcat 7 server.
>
> The login is handeled by j_security_check with a session. When the
> session expires the ajax call from RAP to the server receives the, in
> the web.xml defined, login window.
>
> Ofcourse the clientside ajax parser doesn't understand the login html
> page and pastes it into the screen. Resulting in a whitescreen with:
>
> Could not process server response:
>
> Error: SyntaxError: JSON.parse: unexpected character
>
> Script:
> and a part of the login window.
>
>
> This is not very pleasant in a production environment, so we would like
> to disable the clientside error javascript messages and let it just
> redirect to the login screen. But there is no information to be found on
> the internet about this issue.
>
> Is there anybody that knows how to remove the clientside error when the
> ajax call fails?
>
> Thanks in advance,
> Wouter
>
>
--
Rüdiger Herrmann
http://codeaffine.com
|
|
|
Re: Client-side javascript error on session timout [message #1005503 is a reply to message #897437] |
Fri, 25 January 2013 12:49   |
Eclipse User |
|
|
|
Hello,
I tried to workaround the issue described by Wouter R like this
RWT.getUISession().addUISessionListener(new UISessionListener() {
@Override
public void beforeDestroy(UISessionEvent pEvent) {
pEvent.getUISession().getClient().getService( JavaScriptExecutor.class ).execute("window.setTimeout(function() {window.location.href = '.'}, 1);");
}
});
In order to try to move outside the RAP page, and avoid the ugly parsing error page when session times out, but for some reasons, this does not work, the beforeDestroy is called at the end of the session, but the code does nothing.
Even if this
getClient().getService( JavaScriptExecutor.class ).execute("window.setTimeout(function() {window.location.href = '.'}, 1);");
is working called from a button selection for example
I noticed In RAP 2.0 there is a support for redirect in protocol (https://bugs.eclipse.org/bugs/show_bug.cgi?id=388249)
Is it possible in server code to send a redirect message to web client in beforeDestroy ? (if yes maybe that could help to workaround to this issue)
Thanks,
Regards,
Arnaud
|
|
|
|
|
|
|
|
Re: Client-side javascript error on session timout [message #1690975 is a reply to message #1016366] |
Wed, 01 April 2015 07:28  |
Eclipse User |
|
|
|
Just reading through this thread, the solution seems to be approximately what I am looking for... however... I'm unsure of 'where' to implement the code.
Previously I have used settings for forms within JBoss, WebSphere, Tomcat etc. to specify a redirect URL when the session expires, which is quite complex for what I am trying to achieve. Ideally I would like to programatically define a URL to use for redirect on session timeout, but cannot see how to apply this.
As well as supporting running under a 'proper' AppServer (as mentioned above), I also need a generic solution that will work under OSGi standalone too.
Is there any such solution, perhaps provided by the RAP framework?
Can some JS be injected into my application's start page somehow that sets up the redirect in preparation for a session time-out?
I understand that the redirect logic cannot be triggered directly in the RAP runtime, as this is 'server-side' and hence the connection to the browser is gone by the time the session time-out occurs, but I can work out the correct redirect URL early in the application's life and provide it to the browser somehow while it is alive, so it knows what to do when a time-out does occur... but how to do this?
Thanks,
John
|
|
|
Powered by
FUDForum. Page generated in 0.04489 seconds