01: package org.hamletsoft.enhydra.cactus.presentation.sample;
02:
03: import com.lutris.appserver.server.httpPresentation.HttpPresentation;
04: import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
05: import java.util.Map;
06: import java.util.HashMap;
07: import java.util.Enumeration;
08: import javax.servlet.http.Cookie;
09:
10: /**
11: * SamplePO.java <br>
12: * Test sample presentation object for Enhydra Testing framework using Jakarta Cactus.
13: *
14: * Created: Thu Jan 31 11:29:30 2002
15: *
16: * @author <a href="mailto:hattori@hitachizosen.co.jp">Ryuji Hattori</a>
17: * @version
18: */
19:
20: public class SamplePO implements HttpPresentation {
21:
22: // public SamplePO (){;}
23: // implementation of com.lutris.appserver.server.httpPresentation.HttpPresentation interface
24:
25: public static final String Answer1 = "<html><head/><body>A GET request</body></html>";
26: private String method = null;
27: private Map headers = new HashMap();
28: private Map params = new HashMap();
29: private Map cookies = new HashMap();
30:
31: /**
32: *
33: * @param comms <description>
34: * @exception java.lang.Exception <description>
35: */
36: public void run(HttpPresentationComms comms) throws Exception {
37:
38: method = comms.request.getMethod();
39:
40: for (Enumeration em = comms.request.getParameterNames(); em
41: .hasMoreElements();) {
42: String key = (String) em.nextElement();
43: String value = comms.request.getParameter(key);
44: params.put(key, value);
45: }
46: for (Enumeration em = comms.request.getHeaderNames(); em
47: .hasMoreElements();) {
48: String key = (String) em.nextElement();
49: String value = comms.request.getHeader(key);
50: headers.put(key, value);
51: }
52: Cookie[] cookieArray = comms.request.getCookies();
53: if (cookieArray != null) {
54: for (int i = 0; i < cookieArray.length; i++) {
55: Cookie cookie = cookieArray[i];
56: cookies.put(cookie.getName(), cookie.getValue());
57: }
58: }
59: comms.response.writeHTML(Answer1);
60: }
61:
62: public String checkMethod() {
63: return method;
64: }
65:
66: public Map getRequestParameters() {
67: return params;
68: }
69:
70: public String getRequestHeader(String name) {
71: return (String) headers.get(name);
72: }
73:
74: public Map getRequestCookies() {
75: return cookies;
76: }
77:
78: }// SamplePO
|