I am using encountering an issue where the DHTMLX Ajax postSync doesn’t seem to allow the Browser to handle a partial-response redirect as expected.
Response:
Error seen:
unterminated regular expression literal
…machine:3333/CD/login/’></partial-response
--------------------------------------------------^
Is there something I can do to format the response so it can pass through correctly?
JavaScript Ajax call:
configLoader = dhtmlxAjax.postSync("/CD/setDbBackupConfig",configParams);
tempResult = eval(’(’ + configLoader.xmlDoc.responseText + ‘)’);
Java code intercepts this request and forces the redirect response:
…
if(isAJAX) {
String url = MessageFormat.format(
"{0}://{1}:{2,number,####0}{3}/login/",
request.getScheme(), request.getServerName(),
request.getServerPort(),
httpServletRequest.getContextPath());
PrintWriter pw = response.getWriter();
pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
pw.println("<partial-response><redirect url=\'" + url + "\'></redirect></partial-response>");
pw.flush();
}
…
Context as to why I am doing this:
My application uses Spring security 3.0. That security redirects the user to a timeout page is the session has expired. BUT out-of-the-box it simply returns the entire HTML timeout page to any AJAX requests that happen once the session has expired - certainly not what the AJAX call expects. Our desired way to handle this is server side - So, I have added a filter to this security filter chain that intercepts the request, checks to see if it is AJAX, and is attempting to respond with a redirect response that gets the user to the timeout page. Everything seems to be working with the exception of the client interpretation of the redirect.