1
|
=== modified file 'src/com/goldencode/p2j/main/WebHandler.java'
|
2
|
--- src/com/goldencode/p2j/main/WebHandler.java 2016-02-05 10:30:29 +0000
|
3
|
+++ src/com/goldencode/p2j/main/WebHandler.java 2016-02-05 10:46:24 +0000
|
4
|
@@ -19,8 +19,9 @@
|
5
|
** 007 OM 20150108 Passed null map as additional environment to WebClientSpawner.spawn().
|
6
|
** 008 GES 20150127 Cleanup code formatting.
|
7
|
** 009 GES 20150311 Modified this to support both chui and gui web clients.
|
8
|
-** 010 SBI 20160128 Changed the redirect HTTP response to the "text/html" response containing
|
9
|
-** the redirect path in its body.
|
10
|
+** 010 SBI 20160205 Changed the redirect HTTP response to the "text/html" response containing
|
11
|
+** the redirect path in its body and changed the error page response to
|
12
|
+** the error message to the ajax client.
|
13
|
*/
|
14
|
|
15
|
package com.goldencode.p2j.main;
|
16
|
@@ -265,31 +266,7 @@
|
17
|
HttpServletRequest request,
|
18
|
HttpServletResponse response)
|
19
|
{
|
20
|
- response.setContentType(MimeTypes.Type.TEXT_HTML.asString());
|
21
|
- response.setStatus(HttpServletResponse.SC_OK);
|
22
|
- response.setHeader(HttpHeader.CACHE_CONTROL.asString(),
|
23
|
- "no-cache, no-store, must-revalidate");
|
24
|
- response.setDateHeader(HttpHeader.EXPIRES.asString(), 0);
|
25
|
-
|
26
|
- try
|
27
|
- {
|
28
|
- PrintWriter writer = response.getWriter();
|
29
|
- writer.println(remoteUri);
|
30
|
- writer.flush();
|
31
|
- }
|
32
|
- catch (IOException ioe)
|
33
|
- {
|
34
|
- LOG.logp(Level.SEVERE,
|
35
|
- "WebHandler.sendRedirectPath()",
|
36
|
- "",
|
37
|
- LogHelper.generate("IOException!"),
|
38
|
- ioe);
|
39
|
- }
|
40
|
- finally
|
41
|
- {
|
42
|
- // mark the request as handled
|
43
|
- base.setHandled(true);
|
44
|
- }
|
45
|
+ sendMsgToAjaxClient(HttpServletResponse.SC_OK, remoteUri, base, request, response);
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
@@ -310,8 +287,32 @@
|
50
|
HttpServletRequest request,
|
51
|
HttpServletResponse response)
|
52
|
{
|
53
|
+ sendMsgToAjaxClient(HttpServletResponse.SC_UNAUTHORIZED, error, base, request, response);
|
54
|
+ }
|
55
|
+
|
56
|
+ /**
|
57
|
+ * Sends the message to the ajax client.
|
58
|
+ *
|
59
|
+ * @param status
|
60
|
+ * The http response status.
|
61
|
+ * @param msg
|
62
|
+ * The message to the client.
|
63
|
+ * @param base
|
64
|
+ * The base request.
|
65
|
+ * @param request
|
66
|
+ * The http request.
|
67
|
+ * @param response
|
68
|
+ * The http response.
|
69
|
+ */
|
70
|
+ private void sendMsgToAjaxClient(
|
71
|
+ int status,
|
72
|
+ String msg,
|
73
|
+ Request base,
|
74
|
+ HttpServletRequest request,
|
75
|
+ HttpServletResponse response)
|
76
|
+ {
|
77
|
response.setContentType(MimeTypes.Type.TEXT_HTML.asString());
|
78
|
- response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
79
|
+ response.setStatus(status);
|
80
|
response.setHeader(HttpHeader.CACHE_CONTROL.asString(),
|
81
|
"no-cache, no-store, must-revalidate");
|
82
|
response.setDateHeader(HttpHeader.EXPIRES.asString(), 0);
|
83
|
@@ -319,7 +320,7 @@
|
84
|
try
|
85
|
{
|
86
|
PrintWriter writer = response.getWriter();
|
87
|
- writer.println(error);
|
88
|
+ writer.println(msg);
|
89
|
writer.flush();
|
90
|
}
|
91
|
catch (IOException ioe)
|
92
|
@@ -336,7 +337,7 @@
|
93
|
base.setHandled(true);
|
94
|
}
|
95
|
}
|
96
|
-
|
97
|
+
|
98
|
/**
|
99
|
* Process the given string and make any replacements of parameter
|
100
|
* values as needed. The replacement placeholder follow the JEE
|
101
|
|