1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.fckeditor.tool;
22
23 import javax.servlet.http.HttpServletRequest;
24
25 import net.fckeditor.handlers.ConnectorHandler;
26 import net.fckeditor.handlers.ResourceTypeHandler;
27
28
29
30
31
32
33 public class UtilsResponse {
34
35
36
37
38
39
40
41
42
43
44
45
46 public static String constructResponseUrl(HttpServletRequest request,
47 ResourceTypeHandler resourceType, String urlPath,
48 boolean prependContextPath, boolean fullUrl) {
49
50 StringBuffer sb = new StringBuffer();
51
52 if (fullUrl) {
53 String address = request.getRequestURL().toString();
54 sb.append(address.substring(0, address.indexOf('/', 8))
55 + request.getContextPath());
56 }
57
58 if (prependContextPath && !fullUrl)
59 sb.append(request.getContextPath());
60
61 sb.append(ConnectorHandler.getUserFilesPath(request));
62 sb.append(resourceType.getPath());
63
64 if (Utils.isNotEmpty(urlPath))
65 sb.append(urlPath);
66
67 return sb.toString();
68 }
69
70 }