/**
* This method assures that all pending variable changes are sent to server.
* Method uses synchronized xmlhttprequest and does not return before the
- * changes are sent. No UIDL updates are processed and thut UI is left in
+ * changes are sent. No UIDL updates are processed and thus UI is left in
* inconsistent state. This method should be called only when closing
* windows - normally sendPendingVariableChanges() should be used.
*/
* Build the variable burst and send it to server.
*
* When sync is forced, we also force sending of all pending variable-bursts
- * at the same time. This is ok as we can assume that DOM will newer be
+ * at the same time. This is ok as we can assume that DOM will never be
* updated after this.
*
* @param pendingVariables
- * Vector of variablechanges to send
+ * Vector of variable changes to send
* @param forceSync
* Should we use synchronous request?
*/
RequestType requestType = getRequestType(request);
try {
+ // If a duplicate "close application" URL is received for an
+ // application that is not open, redirect to the application's main
+ // page.
+ // This is needed as e.g. Spring Security remembers the last
+ // URL from the application, which is the logout URL, and repeats
+ // it.
+ // We can tell apart a real onunload request from a repeated one
+ // based on the real one having content (at least the UIDL security
+ // key).
+ if (requestType == RequestType.UIDL
+ && request.getParameterMap().containsKey(
+ ApplicationConnection.PARAM_UNLOADBURST)
+ && request.getContentLength() < 1
+ && getExistingApplication(request, false) == null) {
+ redirectToApplication(request, response);
+ return;
+ }
+
// Find out which application this request is related to
application = findApplicationInstance(request, requestType);
if (application == null) {
return string;
}
+ /**
+ * Write a redirect response to the main page of the application.
+ *
+ * @param request
+ * @param response
+ * @throws IOException
+ * if sending the redirect fails due to an input/output error or
+ * a bad application URL
+ */
+ private void redirectToApplication(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ String applicationUrl = getApplicationUrl(request).toExternalForm();
+ response.sendRedirect(response.encodeRedirectURL(applicationUrl));
+ }
+
/**
*
* @param request