1 15 package org.apache.tapestry.request; 16 17 import java.util.ArrayList ; 18 import java.util.Enumeration ; 19 import java.util.List ; 20 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 import javax.servlet.http.HttpSession ; 24 25 import org.apache.tapestry.ApplicationServlet; 26 27 49 50 public class RequestContext 51 { 52 private final HttpServletRequest _request; 53 54 private final HttpServletResponse _response; 55 56 public RequestContext(HttpServletRequest request, HttpServletResponse response) 57 { 58 59 _request = request; 60 _response = response; 61 } 62 63 68 69 public String getParameter(String name) 70 { 71 return _request.getParameter(name); 72 } 73 74 79 80 public Object getAttribute(String name) 81 { 82 return _request.getAttribute(name); 83 } 84 85 91 92 public String [] getParameters(String name) 93 { 94 return _request.getParameterValues(name); 95 } 96 97 public String [] getParameterNames() 98 { 99 Enumeration e = _request.getParameterNames(); 100 List names = new ArrayList (); 101 102 while (e.hasMoreElements()) 103 names.add(e.nextElement()); 104 105 int count = names.size(); 106 107 String [] result = new String [count]; 108 109 return (String []) names.toArray(result); 110 } 111 112 118 119 public HttpServletRequest getRequest() 120 { 121 return _request; 122 } 123 124 public HttpServletResponse getResponse() 125 { 126 return _response; 127 } 128 129 134 135 public HttpSession getSession() 136 { 137 return _request.getSession(false); 138 } 139 140 144 145 public HttpSession createSession() 146 { 147 return _request.getSession(true); 148 } 149 150 } | Popular Tags |