=== modified file 'src/com/goldencode/p2j/main/WebHandler.java' --- src/com/goldencode/p2j/main/WebHandler.java 2016-02-05 10:30:29 +0000 +++ src/com/goldencode/p2j/main/WebHandler.java 2016-02-05 10:46:24 +0000 @@ -19,8 +19,9 @@ ** 007 OM 20150108 Passed null map as additional environment to WebClientSpawner.spawn(). ** 008 GES 20150127 Cleanup code formatting. ** 009 GES 20150311 Modified this to support both chui and gui web clients. -** 010 SBI 20160128 Changed the redirect HTTP response to the "text/html" response containing -** the redirect path in its body. +** 010 SBI 20160205 Changed the redirect HTTP response to the "text/html" response containing +** the redirect path in its body and changed the error page response to +** the error message to the ajax client. */ package com.goldencode.p2j.main; @@ -265,31 +266,7 @@ HttpServletRequest request, HttpServletResponse response) { - response.setContentType(MimeTypes.Type.TEXT_HTML.asString()); - response.setStatus(HttpServletResponse.SC_OK); - response.setHeader(HttpHeader.CACHE_CONTROL.asString(), - "no-cache, no-store, must-revalidate"); - response.setDateHeader(HttpHeader.EXPIRES.asString(), 0); - - try - { - PrintWriter writer = response.getWriter(); - writer.println(remoteUri); - writer.flush(); - } - catch (IOException ioe) - { - LOG.logp(Level.SEVERE, - "WebHandler.sendRedirectPath()", - "", - LogHelper.generate("IOException!"), - ioe); - } - finally - { - // mark the request as handled - base.setHandled(true); - } + sendMsgToAjaxClient(HttpServletResponse.SC_OK, remoteUri, base, request, response); } /** @@ -310,8 +287,32 @@ HttpServletRequest request, HttpServletResponse response) { + sendMsgToAjaxClient(HttpServletResponse.SC_UNAUTHORIZED, error, base, request, response); + } + + /** + * Sends the message to the ajax client. + * + * @param status + * The http response status. + * @param msg + * The message to the client. + * @param base + * The base request. + * @param request + * The http request. + * @param response + * The http response. + */ + private void sendMsgToAjaxClient( + int status, + String msg, + Request base, + HttpServletRequest request, + HttpServletResponse response) + { response.setContentType(MimeTypes.Type.TEXT_HTML.asString()); - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + response.setStatus(status); response.setHeader(HttpHeader.CACHE_CONTROL.asString(), "no-cache, no-store, must-revalidate"); response.setDateHeader(HttpHeader.EXPIRES.asString(), 0); @@ -319,7 +320,7 @@ try { PrintWriter writer = response.getWriter(); - writer.println(error); + writer.println(msg); writer.flush(); } catch (IOException ioe) @@ -336,7 +337,7 @@ base.setHandled(true); } } - + /** * Process the given string and make any replacements of parameter * values as needed. The replacement placeholder follow the JEE