1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
package org.apache.tapestry.describe; |
16 | |
|
17 | |
import java.util.Iterator; |
18 | |
import java.util.List; |
19 | |
|
20 | |
import javax.servlet.http.HttpServletRequest; |
21 | |
|
22 | |
import org.apache.tapestry.web.WebUtils; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public class HttpServletRequestStrategy implements DescribableStrategy |
31 | |
{ |
32 | |
|
33 | |
public void describeObject(Object object, DescriptionReceiver receiver) |
34 | |
{ |
35 | 0 | HttpServletRequest request = (HttpServletRequest) object; |
36 | |
|
37 | 0 | receiver.title("HttpServletRequest"); |
38 | 0 | receiver.property("authType", request.getAuthType()); |
39 | 0 | receiver.property("characterEncoding", request.getCharacterEncoding()); |
40 | 0 | receiver.property("contentLength", request.getContentLength()); |
41 | 0 | receiver.property("contextPath", request.getContextPath()); |
42 | 0 | receiver.property("contentType", request.getContentType()); |
43 | 0 | receiver.array("cookies", request.getCookies()); |
44 | 0 | receiver.property("locale", request.getLocale()); |
45 | 0 | receiver.property("method", request.getMethod()); |
46 | 0 | receiver.property("pathInfo", request.getPathInfo()); |
47 | 0 | receiver.property("pathTranslated", request.getPathTranslated()); |
48 | 0 | receiver.property("protocol", request.getProtocol()); |
49 | 0 | receiver.property("queryString", request.getQueryString()); |
50 | 0 | receiver.property("requestURI", request.getRequestURI()); |
51 | 0 | receiver.property("scheme", request.getScheme()); |
52 | 0 | receiver.property("secure", request.isSecure()); |
53 | 0 | receiver.property("serverName", request.getServerName()); |
54 | 0 | receiver.property("serverPort", request.getServerPort()); |
55 | 0 | receiver.property("servletPath", request.getServletPath()); |
56 | 0 | receiver.property("userPrincipal", request.getUserPrincipal()); |
57 | |
|
58 | 0 | receiver.section("Parameters"); |
59 | |
|
60 | 0 | List keys = WebUtils.toSortedList(request.getParameterNames()); |
61 | 0 | Iterator i = keys.iterator(); |
62 | 0 | while(i.hasNext()) |
63 | |
{ |
64 | 0 | String key = (String) i.next(); |
65 | 0 | String[] values = request.getParameterValues(key); |
66 | |
|
67 | 0 | receiver.array(key, values); |
68 | 0 | } |
69 | |
|
70 | 0 | receiver.section("Headers"); |
71 | 0 | keys = WebUtils.toSortedList(request.getHeaderNames()); |
72 | 0 | i = keys.iterator(); |
73 | 0 | while(i.hasNext()) |
74 | |
{ |
75 | 0 | String key = (String) i.next(); |
76 | 0 | String value = request.getHeader(key); |
77 | |
|
78 | 0 | receiver.property(key, value); |
79 | 0 | } |
80 | |
|
81 | 0 | receiver.section("Attributes"); |
82 | 0 | keys = WebUtils.toSortedList(request.getAttributeNames()); |
83 | 0 | i = keys.iterator(); |
84 | 0 | while(i.hasNext()) |
85 | |
{ |
86 | 0 | String key = (String) i.next(); |
87 | 0 | Object value = request.getAttribute(key); |
88 | |
|
89 | 0 | receiver.property(key, value); |
90 | 0 | } |
91 | 0 | } |
92 | |
|
93 | |
} |