Annotation of java/classes/org/w3c/jigsaw/servlet/JigsawHttpServletRequest.java, revision 1.74
1.1 abaird 1: // JigsawHttpServletRequest.java
1.74 ! ylafon 2: // $Id: JigsawHttpServletRequest.java,v 1.73 2007/09/28 14:29:57 ylafon Exp $
1.66 ylafon 3: // (c) COPYRIGHT MIT, ERCIM and Keio, 1996-2004.
1.1 abaird 4: // Please first read the full copyright statement in file COPYRIGHT.html
5:
1.16 bmahe 6: package org.w3c.jigsaw.servlet;
1.1 abaird 7:
1.57 ylafon 8: import java.io.BufferedReader;
9: import java.io.IOException;
10: import java.io.InputStream;
11: import java.io.InputStreamReader;
1.60 ylafon 12: import java.io.PipedInputStream;
1.57 ylafon 13: import java.io.Reader;
14: import java.io.StringReader;
15: import java.io.UnsupportedEncodingException;
1.74 ! ylafon 16: import java.net.MalformedURLException;
1.63 ylafon 17: import java.net.URL;
1.74 ! ylafon 18: import java.security.Principal;
1.57 ylafon 19: import java.util.Enumeration;
20: import java.util.Hashtable;
21: import java.util.Locale;
1.60 ylafon 22: import java.util.Map;
1.57 ylafon 23: import java.util.Vector;
24: import javax.servlet.RequestDispatcher;
25: import javax.servlet.Servlet;
1.63 ylafon 26: import javax.servlet.ServletContext;
1.57 ylafon 27: import javax.servlet.ServletInputStream;
28: import javax.servlet.http.Cookie;
29: import javax.servlet.http.HttpServletRequest;
30: import javax.servlet.http.HttpSession;
1.74 ! ylafon 31: import org.w3c.jigsaw.auth.AuthFilter;
! 32: import org.w3c.jigsaw.forms.URLDecoder;
! 33: import org.w3c.jigsaw.forms.URLDecoderException;
! 34: import org.w3c.jigsaw.http.Client;
! 35: import org.w3c.jigsaw.http.Request;
! 36: import org.w3c.jigsaw.http.httpd;
! 37: import org.w3c.tools.resources.InvalidResourceException;
! 38: import org.w3c.tools.resources.Resource;
! 39: import org.w3c.tools.resources.ResourceReference;
1.57 ylafon 40: import org.w3c.util.ArrayEnumeration;
41: import org.w3c.util.EmptyEnumeration;
42: import org.w3c.util.ObservableProperties;
43: import org.w3c.www.http.ContentLengthInputStream;
44: import org.w3c.www.http.HeaderDescription;
45: import org.w3c.www.http.HeaderValue;
46: import org.w3c.www.http.HttpAcceptLanguage;
47: import org.w3c.www.http.HttpCookie;
48: import org.w3c.www.http.HttpCookieList;
49: import org.w3c.www.mime.MimeType;
50:
1.6 abaird 51: class HeaderNames implements Enumeration {
1.18 bmahe 52: // The HeaderDescription enumeration
53: Enumeration e = null;
1.6 abaird 54:
1.18 bmahe 55: public boolean hasMoreElements() {
1.74 ! ylafon 56: return e.hasMoreElements();
1.18 bmahe 57: }
58:
59: public Object nextElement() {
1.74 ! ylafon 60: HeaderDescription d = (HeaderDescription) e.nextElement();
! 61: return d.getName();
1.18 bmahe 62: }
63:
64: HeaderNames(Enumeration e) {
1.74 ! ylafon 65: this.e = e;
1.18 bmahe 66: }
1.6 abaird 67:
68: }
69:
1.2 abaird 70: /**
1.74 ! ylafon 71: * @author Alexandre Rafalovitch <alex@access.com.au>
! 72: * @author Anselm Baird-Smith <abaird@w3.org>
! 73: * @author Benoit Mahe <bmahe@sophia.inria.fr>
! 74: * @author Yves Lafon <ylafon@w3.org>
1.2 abaird 75: */
1.1 abaird 76:
77: public class JigsawHttpServletRequest implements HttpServletRequest {
1.9 bmahe 78:
1.61 ylafon 79: // for null encoding
80: private static final String nullEnc = "null".intern();
1.25 bmahe 81: /**
82: * The InputStream state codes.
83: */
84:
85: /**
1.74 ! ylafon 86: * The initial state of the request InputStream
1.25 bmahe 87: */
1.18 bmahe 88: private final static int STREAM_STATE_INITIAL = 0;
1.25 bmahe 89:
90: /**
91: * One reader has been created and is probably used.
92: */
1.18 bmahe 93: private final static int STREAM_READER_USED = 1;
1.25 bmahe 94:
95: /**
96: * The input stream is used
97: */
1.18 bmahe 98: private final static int INPUT_STREAM_USED = 2;
99:
1.25 bmahe 100: /**
101: * The inputstream state
102: */
1.18 bmahe 103: private int stream_state = STREAM_STATE_INITIAL;
104:
1.74 ! ylafon 105: public final static
! 106: String STATE_PARAMETERS = "org.w3c.jigsaw.servlet.stateParam";
1.18 bmahe 107:
1.74 ! ylafon 108: private static MimeType type = MimeType.APPLICATION_X_WWW_FORM_URLENCODED;
! 109: /**
1.18 bmahe 110: * The initial request.
111: */
112: private Request request = null;
113: /**
114: * The attached servlet.
115: */
116: private Servlet servlet = null;
117: /**
1.63 ylafon 118: * The attached servlet context.
119: */
120: private JigsawServletContext servletContext = null;
121: /**
1.18 bmahe 122: * The lazyly computed queryParameters hashtable.
123: */
124: private Hashtable queryParameters = null;
1.25 bmahe 125: protected JigsawHttpServletResponse response = null;
126:
127: protected JigsawHttpSession httpSession = null;
128:
1.29 bmahe 129: protected JigsawHttpSessionContext sessionContext = null;
1.25 bmahe 130:
131: protected String requestedSessionID = null;
132:
1.60 ylafon 133: protected String encoding = null;
134:
1.64 ylafon 135: private Hashtable convertParameters(Hashtable source) {
1.74 ! ylafon 136: if (source != null) {
! 137: Enumeration e = source.keys();
! 138: while (e.hasMoreElements()) {
! 139: Object name = e.nextElement();
! 140: Object value = source.get(name);
! 141: if (value instanceof String) {
! 142: String _newval[] = new String[1];
! 143: _newval[0] = (String) value;
! 144: source.put(name, _newval);
! 145: }
! 146: }
! 147: return source;
! 148: }
! 149: return null;
1.64 ylafon 150: }
151:
1.45 bmahe 152: private Hashtable mergeParameters(Hashtable source, Hashtable dest) {
1.74 ! ylafon 153: if (source == null)
! 154: return dest;
! 155: if (dest != null) {
! 156: Enumeration e = source.keys();
! 157: while (e.hasMoreElements()) {
! 158: String name = (String) e.nextElement();
! 159: Object value = dest.get(name);
! 160: if (value == null)
! 161: dest.put(name, source.get(name));
! 162: else if (value instanceof String[]) {
! 163: String oldValues[] = (String[]) value;
! 164: String newValues[] = new String[oldValues.length + 1];
! 165: System.arraycopy(oldValues, 0, newValues, 0,
! 166: oldValues.length);
! 167: newValues[oldValues.length] = (String) source.get(name);
! 168: dest.put(name, newValues);
! 169: } else {
! 170: String newValues[] = new String[2];
! 171: newValues[0] = (String) source.get(name);
! 172: newValues[1] = (String) value;
! 173: dest.put(name, newValues);
! 174: }
! 175: }
! 176: return dest;
! 177: } else {
! 178: return source;
! 179: }
1.45 bmahe 180: }
181:
182: private synchronized void prepareQueryParameters() {
1.74 ! ylafon 183: if (queryParameters != null)
! 184: return;
! 185: Hashtable postParameters = null;
! 186: // What kinf of parameters are we expecting ?
! 187: if (request.getMethod().equals("POST")) {
! 188: // POSTed parameters, check content type:
! 189: if ((!request.hasContentType())
! 190: || (type.match(request.getContentType()) < 0))
! 191: return;
! 192: postParameters = new Hashtable(2);
! 193: // Get and decode the request entity:
! 194: URLDecoder dec = null;
! 195: try {
! 196: Reader in = getReader();
! 197: // Notify the client that we are willing to continue
! 198: String exp = request.getExpect();
! 199: if (exp != null && (exp.equalsIgnoreCase("100-continue"))) {
! 200: Client client = request.getClient();
! 201: if (client != null) {
! 202: client.sendContinue();
! 203: }
! 204: }
! 205: String encoding = getCharacterEncoding();
! 206: if (encoding == null) {
! 207: dec = new URLDecoder(in, false, "8859_1");
! 208: } else {
! 209: dec = new URLDecoder(in, false, getCharacterEncoding());
! 210: }
! 211: postParameters = dec.parse();
! 212: } catch (URLDecoderException e) {
! 213: postParameters = null;
! 214: } catch (IOException ex) {
! 215: postParameters = null;
! 216: }
! 217: }
! 218: // URL encoded parameters:
! 219: String query = getQueryString();
! 220: if (query != null) {
! 221: Reader qis = null;
! 222: qis = new StringReader(query);
! 223: try {
! 224: URLDecoder dec;
! 225: String encoding = getCharacterEncoding();
! 226: if (encoding == null) {
! 227: dec = new URLDecoder(qis, false, "8859_1");
! 228: } else {
! 229: dec = new URLDecoder(qis, false, getCharacterEncoding());
! 230: }
! 231: queryParameters = dec.parse();
! 232: } catch (Exception ex) {
! 233: throw new RuntimeException("Java implementation bug.");
! 234: }
! 235: }
! 236: queryParameters = mergeParameters(postParameters, queryParameters);
! 237: // state parameters
! 238: Hashtable param = (Hashtable) request.getState(STATE_PARAMETERS);
! 239: queryParameters = mergeParameters(param, queryParameters);
! 240: convertParameters(queryParameters);
1.18 bmahe 241: }
242:
1.31 bmahe 243: protected String getURLParameter(String name) {
1.74 ! ylafon 244: Hashtable urlParameters = null;
! 245: String query = getQueryString();
! 246: if (query != null) {
! 247: Reader qis = new StringReader(query);
! 248: try {
! 249: String encoding = getCharacterEncoding();
! 250: if (encoding == null) {
! 251: urlParameters = new URLDecoder(qis, false, "8859_1").parse();
! 252: } else {
! 253: urlParameters = new URLDecoder(qis, false, encoding).parse();
! 254: }
! 255: return (String) urlParameters.get(name);
! 256: } catch (Exception ex) {
! 257: throw new RuntimeException("Java implementation bug.");
! 258: }
! 259: }
! 260: return null;
1.31 bmahe 261: }
1.18 bmahe 262:
263: /**
264: * Return the Charset parameter of content type
1.74 ! ylafon 265: *
1.18 bmahe 266: * @return A String instance
267: */
268: public String getCharacterEncoding() {
1.74 ! ylafon 269: if (encoding == null) {
! 270: org.w3c.www.mime.MimeType type = request.getContentType();
! 271: if ((type != null) && (type.hasParameter("charset"))) {
! 272: encoding = type.getParameterValue("charset");
! 273: } else {
! 274: encoding = nullEnc;
! 275: }
! 276: }
! 277: if (encoding == nullEnc) {
! 278: return null;
! 279: }
! 280: return encoding;
1.60 ylafon 281: }
282:
283: /**
284: * Overrides the name of the character encoding used in the body of this
285: * request
286: * ServletRequest implementation - version 2.3
1.74 ! ylafon 287: *
1.60 ylafon 288: * @param enc, a <code>String</code> specifying the encoding String
289: */
1.74 ! ylafon 290: public void setCharacterEncoding(String enc)
! 291: throws java.io.UnsupportedEncodingException {
! 292: // a hack to see if the character encoding is supported
! 293: InputStreamReader isr = new InputStreamReader(new PipedInputStream(),
! 294: enc);
! 295: encoding = enc;
1.18 bmahe 296: }
297:
298: /**
299: * ServletRequest implementation - Get the length of request data.
1.74 ! ylafon 300: *
1.18 bmahe 301: * @return An int, or <strong>-1</strong>.
302: */
303:
1.52 bmahe 304: public int getContentLength() {
1.74 ! ylafon 305: long rl = request.getContentLength();
! 306: if (rl > (long) Integer.MAX_VALUE) {
! 307: return -1;
! 308: }
! 309: return (int) rl;
1.18 bmahe 310: }
311:
312: /**
313: * ServletRequest implementation - Get the type of the request's body.
1.74 ! ylafon 314: *
1.18 bmahe 315: * @return A String encoded mime type, or <strong>null</strong>.
316: */
317:
1.52 bmahe 318: public String getContentType() {
1.74 ! ylafon 319: org.w3c.www.mime.MimeType t = request.getContentType();
! 320: return (t == null) ? null : t.toString();
1.18 bmahe 321: }
1.57 ylafon 322:
1.18 bmahe 323: /**
324: * ServletRequest implementation - Get the protocol of that request.
1.74 ! ylafon 325: *
1.18 bmahe 326: * @return A String encoded version of the protocol.
327: */
328:
1.52 bmahe 329: public String getProtocol() {
1.74 ! ylafon 330: return request.getVersion();
1.18 bmahe 331: }
1.57 ylafon 332:
1.47 bmahe 333: protected httpd getServer() {
1.74 ! ylafon 334: return request.getClient().getServer();
1.47 bmahe 335: }
336:
1.74 ! ylafon 337: /**
! 338: * ServletRequest implementation - Get the name of queried server.
! 339: *
! 340: * @return Name of server, as a String.
! 341: */
! 342:
! 343: public String getServerName() {
! 344: String host = request.getHost();
! 345: if (host != null) {
! 346: int idx = host.lastIndexOf(':');
! 347: if (idx != -1) {
! 348: return host.substring(0, host.lastIndexOf(':'));
! 349: } else {
! 350: return host;
! 351: }
! 352: } else {
! 353: return getServer().getHost();
! 354: }
! 355: }
! 356:
! 357: /**
! 358: * ServletRequest implementation - Get the port of queried server.
! 359: *
! 360: * @return A port number (int).
! 361: */
! 362:
! 363: public int getServerPort() {
! 364: if (request.isProxy()) {
! 365: String host = request.getHost();
! 366: if (host != null) {
! 367: int idx = host.lastIndexOf(':');
! 368: if (idx == -1)
! 369: return 80;
! 370: return Integer.parseInt(host.substring(idx + 1));
! 371: }
! 372: }
! 373: return getServer().getLocalPort();
! 374: }
! 375:
! 376: /**
! 377: * ServletRequest implementation - Get the IP address of requests's sender.
! 378: *
! 379: * @return Numeric IP address, as a String.
! 380: */
1.18 bmahe 381:
1.52 bmahe 382: public String getRemoteAddr() {
1.74 ! ylafon 383: return request.getClient().getInetAddress().getHostAddress();
1.18 bmahe 384: }
385:
386: /**
387: * ServletRequest implementation - FQDN of request's sender.
1.74 ! ylafon 388: *
1.18 bmahe 389: * @return Name of client's machine (FQDN).
390: */
391:
1.52 bmahe 392: public String getRemoteHost() {
1.74 ! ylafon 393: return request.getClient().getInetAddress().getHostName();
1.18 bmahe 394: }
395:
396: /**
397: * ServletRequest implementation - Get real path.
398: * Jigsaw realy has no notion of <em>translation</em> stricto
399: * sensu (it has much better in fact ;-). This is a pain here.
1.74 ! ylafon 400: *
1.46 bmahe 401: * @return the real path.
1.42 bmahe 402: * @deprecated since jsdk1.2
1.18 bmahe 403: */
404:
405: public String getRealPath(String name) {
1.74 ! ylafon 406: httpd server = getServer();
! 407: ResourceReference rr_root = server.getRootReference();
! 408: return JigsawServletContext.getRealPath(name,
! 409: rr_root,
! 410: request.getTargetResource());
1.18 bmahe 411: }
412:
1.32 bmahe 413: protected ServletInputStream is = null;
414:
1.18 bmahe 415: /**
1.74 ! ylafon 416: * Returns an input stream for reading binary data in the request body.
! 417: *
! 418: * @throws IllegalStateException if getReader has been called on
! 419: * this same request.
! 420: * @throws IOException on other I/O related errors.
1.41 ylafon 421: * @see JigsawHttpServletRequest#getReader
1.74 ! ylafon 422: */
1.18 bmahe 423: public ServletInputStream getInputStream()
1.74 ! ylafon 424: throws IOException {
! 425: if (stream_state == STREAM_READER_USED)
! 426: throw new IllegalStateException("Reader used");
! 427: stream_state = INPUT_STREAM_USED;
! 428: return getJigsawInputStream();
1.18 bmahe 429: }
1.57 ylafon 430:
1.37 bmahe 431: /**
1.74 ! ylafon 432: * @throws IOException if an IO error occurs
! 433: */
1.18 bmahe 434: protected ServletInputStream getJigsawInputStream()
1.74 ! ylafon 435: throws IOException {
! 436: // If alredy computed return:
! 437: if (is != null)
! 438: return is;
! 439: // Built it:
! 440: InputStream stream = null;
! 441: if ((stream = request.getInputStream()) == null) {
! 442: stream = new ContentLengthInputStream(null, 0);
! 443: }
! 444: return is = new JigsawServletInputStream(stream);
1.18 bmahe 445: }
446:
447: /**
448: * ServletRequest implementation - Get a parameter value.
1.74 ! ylafon 449: *
1.18 bmahe 450: * @return The String encoded value for the parameter.
451: */
452:
1.52 bmahe 453: public String getParameter(String name) {
1.74 ! ylafon 454: prepareQueryParameters();
! 455: if (queryParameters != null) {
! 456: Object value = queryParameters.get(name);
! 457: if (value != null) {
! 458: return ((String[]) value)[0];
! 459: }
! 460: }
! 461: return null;
1.60 ylafon 462: }
463:
464: /**
465: * ServletRequest implementation - Get a parameter value. (v2.3)
1.74 ! ylafon 466: *
1.60 ylafon 467: * @return a Map of the parameters in this request
468: */
469: public Map getParameterMap() {
1.74 ! ylafon 470: prepareQueryParameters();
! 471: return queryParameters;
1.18 bmahe 472: }
473:
474: /**
475: * ServletRequest implementation - Get the parameters value.
1.74 ! ylafon 476: *
1.18 bmahe 477: * @return The String array encoded value for the parameter.
478: */
1.57 ylafon 479:
1.18 bmahe 480: public String[] getParameterValues(String parameter) {
1.74 ! ylafon 481: Vector V = new Vector(23);
! 482: prepareQueryParameters();
! 483: if (queryParameters == null) {
! 484: return null;
! 485: }
! 486: Object value = queryParameters.get(parameter);
! 487: if (value == null) {
! 488: return null;
! 489: }
! 490: return (String[]) value;
1.18 bmahe 491: }
492:
493: /**
494: * ServletRequest implementation - List available parameters.
1.74 ! ylafon 495: *
1.18 bmahe 496: * @return An enumeration of parameter names.
497: */
1.57 ylafon 498:
1.52 bmahe 499: public Enumeration getParameterNames() {
1.74 ! ylafon 500: prepareQueryParameters();
! 501: return ((queryParameters == null)
! 502: ? new EmptyEnumeration()
! 503: : queryParameters.keys());
1.18 bmahe 504: }
505:
506: /**
507: * ServletRequest implementation - Get an attribute of the request.
508: * This closely match Jigsaw's notion of request state.
1.74 ! ylafon 509: *
1.18 bmahe 510: * @param name The name of the attribute.
511: * @return An object that gives the value of the attribute.
512: */
513:
514: public Object getAttribute(String name) {
1.74 ! ylafon 515: return request.getState(name);
1.18 bmahe 516: }
517:
1.42 bmahe 518: public void setAttribute(String name, Object object) {
1.74 ! ylafon 519: request.setState(name, object);
1.42 bmahe 520: }
521:
1.47 bmahe 522: /**
523: * Removes an attribute from this request. This method is not
524: * generally needed as attributes only persist as long as the request
525: * is being handled.
1.74 ! ylafon 526: * <p/>
1.47 bmahe 527: * <p>Attribute names should follow the same conventions as
528: * package names. Names beginning with <code>java.*</code>,
529: * <code>javax.*</code>, and <code>com.sun.*</code>, are
530: * reserved for use by Sun Microsystems.
531: *
1.74 ! ylafon 532: * @param name a <code>String</code> specifying
! 533: * the name of the attribute to remove
1.47 bmahe 534: */
535: public void removeAttribute(String name) {
1.74 ! ylafon 536: request.delState(name);
1.47 bmahe 537: }
538:
1.42 bmahe 539: public Enumeration getAttributeNames() {
1.74 ! ylafon 540: return request.getStateNames();
1.42 bmahe 541: }
542:
1.18 bmahe 543: /**
1.74 ! ylafon 544: * Returns the preferred <code>Locale</code> that the client will
1.47 bmahe 545: * accept content in, based on the Accept-Language header.
546: * If the client request doesn't provide an Accept-Language header,
547: * this method returns the default locale for the server.
548: *
549: * @return the preferred <code>Locale</code> for the client
550: */
551: public Locale getLocale() {
1.74 ! ylafon 552: return (Locale) getLocales().nextElement();
1.47 bmahe 553: }
1.57 ylafon 554:
1.47 bmahe 555: /**
556: * Returns an <code>Enumeration</code> of <code>Locale</code> objects
557: * indicating, in decreasing order starting with the preferred locale, the
558: * locales that are acceptable to the client based on the Accept-Language
559: * header.
560: * If the client request doesn't provide an Accept-Language header,
1.74 ! ylafon 561: * this method returns an <code>Enumeration</code> containing one
1.47 bmahe 562: * <code>Locale</code>, the default locale for the server.
563: *
1.74 ! ylafon 564: * @return an <code>Enumeration</code> of preferred
! 565: * <code>Locale</code> objects for the client
1.47 bmahe 566: */
567: public Enumeration getLocales() {
1.74 ! ylafon 568: HttpAcceptLanguage languages[] = request.getAcceptLanguage();
! 569: if (languages == null) {
! 570: Vector def = new Vector();
1.47 bmahe 571: def.addElement(Locale.getDefault());
572: return def.elements();
1.74 ! ylafon 573: }
1.47 bmahe 574:
1.74 ! ylafon 575: //LinkedList is better, but we must be JDK1.1 compliant
! 576: Vector locales = new Vector();
1.47 bmahe 577:
1.74 ! ylafon 578: for (HttpAcceptLanguage language : languages) {
! 579: double quality = language.getQuality();
! 580: String lang = language.getLanguage();
! 581: String country = "";
! 582: int idx = lang.indexOf('-');
! 583: if (idx > -1) {
! 584: country = lang.substring(idx + 1).trim();
! 585: lang = lang.substring(0, idx).trim();
! 586: }
! 587: // insert the Locale in ordered list
! 588: int qidx = 0;
! 589: int size = locales.size();
! 590: if (size > 0) {
! 591: QLocale ql = (QLocale) locales.firstElement();
! 592: while ((qidx < size) && (ql.getLanguageQuality() >= quality)) {
! 593: try {
! 594: ql = (QLocale) locales.elementAt(++qidx);
! 595: } catch (ArrayIndexOutOfBoundsException ex) {
! 596: //end of vector, so append
! 597: }
! 598: }
! 599: locales.insertElementAt(new QLocale(lang, country, quality),
! 600: qidx);
! 601: } else {
! 602: locales.addElement(new QLocale(lang, country, quality));
! 603: }
! 604: }
! 605: // because Locale is final :(
! 606: int size = locales.size();
! 607: Vector vlocale = new Vector(size);
! 608: for (int i = 0; i < size; i++) {
! 609: vlocale.addElement(((QLocale) locales.elementAt(i)).getLocale());
! 610: }
! 611: return vlocale.elements();
1.47 bmahe 612: }
613:
614: /**
615: * Returns a boolean indicating whether this request was made using a
616: * secure channel, such as HTTPS.
617: *
618: * @return a boolean indicating if the request was made using a
1.74 ! ylafon 619: * secure channel
1.47 bmahe 620: */
621:
622: public boolean isSecure() {
1.74 ! ylafon 623: // only https secure?
! 624: return (request.getURL().getProtocol().equalsIgnoreCase("https"));
1.47 bmahe 625: }
1.57 ylafon 626:
1.47 bmahe 627: /**
1.18 bmahe 628: * HttpServletRequest implementation - Get the request's method.
1.74 ! ylafon 629: *
1.18 bmahe 630: * @return A String instance.
631: */
632:
1.74 ! ylafon 633: public String getMethod() {
! 634: return request.getMethod();
1.18 bmahe 635: }
636:
637: /**
638: * HttpServletRequest implementation - Get the request's path info.
1.74 ! ylafon 639: *
1.18 bmahe 640: * @return A String instance or <strong>null</strong>.
641: */
642:
1.74 ! ylafon 643: public String getPathInfo() {
! 644: if (request.hasState(JigsawRequestDispatcher.PATH_INFO_P)) {
! 645: String pathinfo =
! 646: (String) request.getState(JigsawRequestDispatcher.PATH_INFO_P);
! 647: return (pathinfo.equals("/")) ? null : pathinfo;
! 648: }
! 649: return null;
1.18 bmahe 650: }
1.57 ylafon 651:
1.18 bmahe 652: /**
653: * HttpServletRequest implementation - Get the request's path translated.
1.74 ! ylafon 654: *
1.18 bmahe 655: * @return A String instance or <strong>null</strong>.
656: */
1.57 ylafon 657:
1.74 ! ylafon 658: public String getPathTranslated() {
! 659: String pathinfo = getPathInfo();
! 660: if (pathinfo != null)
! 661: return getRealPath(pathinfo);
! 662: return null;
1.18 bmahe 663: }
664:
665: /**
1.47 bmahe 666: * Returns the portion of the request URI that indicates the context
667: * of the request. The context path always comes first in a request
668: * URI. The path starts with a "/" character but does not end with a "/"
669: * character. For servlets in the default (root) context, this method
670: * returns "".
1.74 ! ylafon 671: *
! 672: * @return a <code>String</code> specifying the portion of the request
! 673: * URI that indicates the context of the request
1.47 bmahe 674: */
675: public String getContextPath() {
1.74 ! ylafon 676: return "";
1.47 bmahe 677: }
678:
1.52 bmahe 679: public boolean hasQueryString() {
1.74 ! ylafon 680: if (request.hasQueryString()) {
! 681: return true;
! 682: } else {
! 683: return request.hasState(JigsawRequestDispatcher.QUERY_STRING_P);
! 684: }
1.52 bmahe 685: }
686:
1.47 bmahe 687: /**
1.18 bmahe 688: * HttpServletRequest implementation - Get the request's query string.
1.74 ! ylafon 689: *
1.18 bmahe 690: * @return A String instance or <strong>null</strong>.
691: */
1.52 bmahe 692: public String getQueryString() {
1.74 ! ylafon 693: if (request.hasQueryString()) {
! 694: return request.getQueryString();
! 695: } else if (request.hasState(JigsawRequestDispatcher.QUERY_STRING_P)) {
! 696: return (String)
! 697: request.getState(JigsawRequestDispatcher.QUERY_STRING_P);
! 698: }
! 699: return null;
1.18 bmahe 700: }
1.57 ylafon 701:
1.18 bmahe 702: /**
703: * HttpServletRequest implementation - Get the request's user (if any).
1.74 ! ylafon 704: *
1.18 bmahe 705: * @return A String instance or <strong>null</strong>.
706: */
707:
1.52 bmahe 708: public String getRemoteUser() {
1.74 ! ylafon 709: return (String) request.getState(AuthFilter.STATE_AUTHUSER);
1.18 bmahe 710: }
1.57 ylafon 711:
1.18 bmahe 712: /**
1.47 bmahe 713: * Returns a boolean indicating whether the authenticated user is included
714: * in the specified logical "role". Roles and role membership can be
715: * defined using deployment descriptors. If the user has not been
716: * authenticated, the method returns <code>false</code>.
717: *
718: * @param role a <code>String</code> specifying the name of the role
719: * @return a <code>boolean</code> indicating whether the user making this
1.74 ! ylafon 720: * request belongs to a given role; <code>false</code> if the user has not
! 721: * been authenticated
1.47 bmahe 722: */
723:
724: public boolean isUserInRole(String role) {
1.74 ! ylafon 725: throw new RuntimeException("Not Yet Implemented");
1.47 bmahe 726: }
727:
728: /**
729: * Returns a <code>java.security.Principal</code> object containing
730: * the name of the current authenticated user. If the user has not been
731: * authenticated, the method returns <code>null</code>.
732: *
733: * @return a <code>java.security.Principal</code> containing
1.74 ! ylafon 734: * the name of the user making this request; <code>null</code> if the
! 735: * user has not been authenticated
1.47 bmahe 736: */
737: public Principal getUserPrincipal() {
1.74 ! ylafon 738: return new PrincipalImpl(getRemoteUser());
1.47 bmahe 739: }
740:
741: /**
1.18 bmahe 742: * HttpServletRequest implementation - Get the request's auth method.
1.74 ! ylafon 743: *
1.18 bmahe 744: * @return A String instance or <strong>null</strong>.
745: */
746:
747: public String getAuthType() {
1.74 ! ylafon 748: return (String) request.getState(AuthFilter.STATE_AUTHTYPE);
1.18 bmahe 749: }
750:
751: /**
752: * HttpServletRequest implementation - Get a request header as a String.
1.74 ! ylafon 753: *
1.18 bmahe 754: * @return A String instance or <strong>null</strong>.
755: */
756:
757: public String getHeader(String name) {
1.74 ! ylafon 758: return request.getValue(name);
1.18 bmahe 759: }
760:
761: /**
1.47 bmahe 762: * Returns all the values of the specified request header
763: * as an <code>Enumeration</code> of <code>String</code> objects.
1.74 ! ylafon 764: * <p/>
1.47 bmahe 765: * <p>Some headers, such as <code>Accept-Language</code> can be sent
766: * by clients as several headers each with a different value rather than
767: * sending the header as a comma separated list.
1.74 ! ylafon 768: * <p/>
1.47 bmahe 769: * <p>WARNING, this can't happen with Jigsaw, all multiple values are
1.74 ! ylafon 770: * grouped in one, and only one, header. So, this method always return
1.47 bmahe 771: * ONE header value.
1.74 ! ylafon 772: * <p/>
1.47 bmahe 773: * <p>If the request did not include any headers
774: * of the specified name, this method returns an empty
775: * <code>Enumeration</code>.
776: * The header name is case insensitive. You can use
777: * this method with any request header.
778: *
779: * @param name a <code>String</code> specifying the header name
1.74 ! ylafon 780: * @return a <code>Enumeration</code> containing the values of the
! 781: * requested header, or <code>null</code> if the request does not
! 782: * have any headers of that name
! 783: */
1.47 bmahe 784:
785: public Enumeration getHeaders(String name) {
1.74 ! ylafon 786: String value = getHeader(name);
! 787: String array[] = {value};
! 788: return new ArrayEnumeration(array);
1.47 bmahe 789: }
790:
791: /**
1.18 bmahe 792: * HttpServletRequest implementation - Get a request header as an int.
1.74 ! ylafon 793: *
1.18 bmahe 794: * @return An int, or <strong>-1</strong>.
795: */
796:
797: public int getIntHeader(String name) {
1.74 ! ylafon 798: HeaderValue v = request.getHeaderValue(name);
! 799: if (v != null) {
! 800: Object o = v.getValue();
! 801: if ((o != null) && (o instanceof Integer))
! 802: return ((Integer) o).intValue();
! 803: }
! 804: return -1;
1.1 abaird 805: }
1.18 bmahe 806:
807: /**
808: * HttpServletRequest implementation - Get a request header as an date.
1.74 ! ylafon 809: *
1.18 bmahe 810: * @return An long (as a number of milliseconds), or <strong>-1</strong>.
811: */
812:
813: public long getDateHeader(String name) {
1.74 ! ylafon 814: HeaderValue v = request.getHeaderValue(name, null);
! 815: if (v != null) {
! 816: Object o = v.getValue();
! 817: if ((o != null) && (o instanceof Long))
! 818: return ((Long) o).longValue();
! 819: }
! 820: return (long) -1;
1.1 abaird 821: }
1.8 bmahe 822:
1.18 bmahe 823: /**
824: * HttpServletRequest implementation - Get a all header names.
1.74 ! ylafon 825: *
1.18 bmahe 826: * @return An enumeration.
827: */
828:
829: public Enumeration getHeaderNames() {
1.74 ! ylafon 830: return new HeaderNames(request.enumerateHeaderDescriptions());
1.18 bmahe 831: }
1.16 bmahe 832:
1.25 bmahe 833: /**
1.74 ! ylafon 834: * Gets, from the first line of the HTTP request,
1.25 bmahe 835: * the part of this request's URI that is to the left of any query string.
836: */
1.55 bmahe 837: public String getRequestURI() {
1.74 ! ylafon 838: String uri = null;
! 839: if (request.hasState(JigsawRequestDispatcher.REQUEST_URI_P)) {
! 840: uri = (String)
! 841: request.getState(JigsawRequestDispatcher.REQUEST_URI_P);
! 842: try {
! 843: URL u = new URL(request.getURL(), uri);
! 844: uri = u.getFile();
! 845: } catch (MalformedURLException muex) {
! 846: }
! 847: } else {
! 848: //fixme test
! 849: if (request.isProxy()) {
! 850: uri = request.getURL().toExternalForm();
! 851: } else {
! 852: uri = request.getURLPath();
! 853: }
! 854: if (hasQueryString()) {
! 855: String query = getQueryString();
! 856: int idx = uri.lastIndexOf(query);
! 857: uri = uri.substring(0, idx - 1);
! 858: }
! 859: }
! 860: return uri;
1.18 bmahe 861: }
1.57 ylafon 862:
1.25 bmahe 863: /**
1.74 ! ylafon 864: * Gets, from the first line of the HTTP request,
1.63 ylafon 865: * the part of this request's URI that is to the left of any query string.
866: */
867: public StringBuffer getRequestURL() {
1.74 ! ylafon 868: String uri = null;
! 869: if (request.hasState(JigsawRequestDispatcher.REQUEST_URI_P)) {
! 870: uri = (String)
! 871: request.getState(JigsawRequestDispatcher.REQUEST_URI_P);
! 872: try {
! 873: URL u = new URL(request.getURL(), uri);
! 874: uri = u.toExternalForm();
! 875: } catch (MalformedURLException muex) {
! 876: }
! 877: } else {
! 878: uri = request.getURL().toExternalForm();
! 879: if (hasQueryString()) {
! 880: String query = getQueryString();
! 881: int idx = uri.lastIndexOf(query);
! 882: uri = uri.substring(0, idx - 1);
! 883: }
! 884: }
! 885: return new StringBuffer(uri);
1.63 ylafon 886: }
887:
888: /**
1.47 bmahe 889: * Returns a {@link RequestDispatcher} object that acts as a wrapper for
1.74 ! ylafon 890: * the resource located at the given path.
1.47 bmahe 891: * A <code>RequestDispatcher</code> object can be used to forward
892: * a request to the resource or to include the resource in a response.
893: * The resource can be dynamic or static.
1.74 ! ylafon 894: * <p/>
1.47 bmahe 895: * <p>The pathname specified may be relative, although it cannot extend
1.74 ! ylafon 896: * outside the current servlet context. If the path begins with
! 897: * a "/" it is interpreted as relative to the current context root.
1.47 bmahe 898: * This method returns <code>null</code> if the servlet container
899: * cannot return a <code>RequestDispatcher</code>.
1.74 ! ylafon 900: * <p/>
1.47 bmahe 901: * <p>The difference between this method and {@link
902: * ServletContext#getRequestDispatcher} is that this method can take a
903: * relative path.
904: *
905: * @param path a <code>String</code> specifying the pathname
1.74 ! ylafon 906: * to the resource
! 907: * @return a <code>RequestDispatcher</code> object that acts as a
! 908: * wrapper for the resource at the specified path
1.47 bmahe 909: * @see RequestDispatcher
910: * @see ServletContext#getRequestDispatcher
911: */
912: public RequestDispatcher getRequestDispatcher(String path) {
1.74 ! ylafon 913: if (path == null) {
! 914: throw new IllegalArgumentException("null");
! 915: }
! 916: String urlpath = null;
! 917: ResourceReference rr = request.getTargetResource();
! 918: if (!path.startsWith("/")) {
! 919: String uri = null;
! 920: try {
! 921: ResourceReference rrp = rr.lock().getParent();
! 922: try {
! 923: Resource r = rrp.lock();
! 924: uri = r.getURLPath();
! 925: } catch (InvalidResourceException irex) {
! 926: return null;
! 927: } finally {
! 928: rrp.unlock();
! 929: }
! 930: } catch (InvalidResourceException ex) {
! 931: return null;
! 932: } finally {
! 933: rr.unlock();
! 934: }
! 935: urlpath = (uri.endsWith("/") ? uri + path : uri + "/" + path);
! 936: } else {
! 937: urlpath = path;
! 938: }
! 939: return JigsawRequestDispatcher.getRequestDispatcher(urlpath,
! 940: getServer(),
! 941: rr);
1.47 bmahe 942: }
943:
944: /**
1.74 ! ylafon 945: * Gets the part of this request's URI that refers to the servlet
! 946: * being invoked. Analogous to the CGI variable SCRIPT_NAME.
1.25 bmahe 947: */
1.52 bmahe 948: public String getServletPath() {
1.74 ! ylafon 949: if (request.hasState(JigsawRequestDispatcher.SERVLET_PATH_P)) {
! 950: return (String)
! 951: request.getState(JigsawRequestDispatcher.SERVLET_PATH_P);
! 952: } else {
! 953: ResourceReference rr = request.getTargetResource();
! 954: try {
! 955: return rr.lock().getURLPath();
! 956: } catch (InvalidResourceException ex) {
! 957: return null;
! 958: } finally {
! 959: rr.unlock();
! 960: }
! 961: }
1.18 bmahe 962: }
1.57 ylafon 963:
1.25 bmahe 964: /**
965: * @return the scheme of the URL used in this request, for example "http",
1.74 ! ylafon 966: * "https", or "ftp". Different schemes have different rules
! 967: * for constructing URLs, as noted in RFC 1738. The URL used to create
! 968: * a request may be reconstructed using this scheme, the server name
! 969: * and port, and additional information such as URIs.
1.25 bmahe 970: */
1.18 bmahe 971: public String getScheme() {
1.74 ! ylafon 972: return request.getURL().getProtocol();
1.18 bmahe 973: }
1.16 bmahe 974:
1.25 bmahe 975: /**
976: * Gets the array of cookies found in this request.
1.74 ! ylafon 977: *
1.36 bmahe 978: * @return the array of cookies found in this request or
1.74 ! ylafon 979: * <strong>null</strong> if there is no cookie.
1.25 bmahe 980: */
1.18 bmahe 981: public Cookie[] getCookies() {
1.74 ! ylafon 982: HttpCookieList cookielist = request.getCookie();
! 983: Cookie[] Scookies = null;
! 984: if (cookielist != null) {
! 985: HttpCookie[] cookies = cookielist.getCookies();
! 986: Scookies = new Cookie[cookies.length];
! 987: for (int i = 0; i < cookies.length; i++) {
! 988: Scookies[i] = convertCookie(cookies[i]);
! 989: }
! 990: }
! 991: return Scookies;
1.19 bmahe 992: }
1.57 ylafon 993:
1.19 bmahe 994: protected Cookie convertCookie(HttpCookie httpCookie) {
1.74 ! ylafon 995: Cookie cookie = new Cookie(httpCookie.getName(),
! 996: httpCookie.getValue());
! 997: String val = null;
! 998: if ((val = httpCookie.getDomain()) != null)
! 999: cookie.setDomain(val);
! 1000: if ((val = httpCookie.getPath()) != null)
! 1001: cookie.setPath(val);
! 1002: cookie.setVersion(httpCookie.getVersion());
! 1003: return cookie;
1.19 bmahe 1004: }
1005:
1006: protected String getRequestedSessionIdFromCookie() {
1.74 ! ylafon 1007: HttpCookieList cookielist = request.getCookie();
! 1008: if (cookielist != null) {
! 1009: HttpCookie httpCookie =
! 1010: request.getCookie().getCookie(getCookieName());
! 1011: if (httpCookie != null)
! 1012: return httpCookie.getValue();
! 1013: }
! 1014: return null;
1.18 bmahe 1015: }
1.19 bmahe 1016:
1.31 bmahe 1017: protected String getRequestedSessionIdFromURL() {
1.74 ! ylafon 1018: return getURLParameter(getCookieName());
1.31 bmahe 1019: }
1020:
1.25 bmahe 1021: /**
1.74 ! ylafon 1022: * Gets the session id specified with this request. This may differ
1.25 bmahe 1023: * from the actual session id. For example, if the request specified an
1.74 ! ylafon 1024: * id for an invalid session, then this will get a new session with a
! 1025: * new id.
! 1026: *
! 1027: * @return the session id specified by this request, or null if the
! 1028: * request did not specify a session id.
1.25 bmahe 1029: */
1.18 bmahe 1030: public String getRequestedSessionId() {
1.74 ! ylafon 1031: if (requestedSessionID == null) {
! 1032: requestedSessionID = getRequestedSessionIdFromCookie();
! 1033: if (requestedSessionID == null)
! 1034: requestedSessionID = getRequestedSessionIdFromURL();
! 1035: }
! 1036: return requestedSessionID;
1.19 bmahe 1037: }
1038:
1039: protected synchronized JigsawHttpSessionContext getSessionContext() {
1.74 ! ylafon 1040: return sessionContext;
1.15 benoit 1041: }
1.14 bmahe 1042:
1.25 bmahe 1043: /**
1044: * Gets the current valid session associated with this request, if create
1.74 ! ylafon 1045: * is false or, if necessary, creates a new session for the request, if
! 1046: * create is true.
! 1047: *
! 1048: * @return the session associated with this request or null if create
! 1049: * was false and no valid session is associated with this request.
1.25 bmahe 1050: */
1.18 bmahe 1051: public HttpSession getSession(boolean create) {
1.74 ! ylafon 1052: if (httpSession == null) {
! 1053: httpSession = (JigsawHttpSession)
! 1054: getSession(getRequestedSessionId());
! 1055: if (httpSession != null) // the client join the session
! 1056: httpSession.setNoMoreNew();
! 1057: }
! 1058: if (httpSession == null & create) {
! 1059: httpSession = new JigsawHttpSession(getSessionContext(),
! 1060: servletContext,
! 1061: createCookie());
! 1062: response.addCookie(httpSession.getCookie());
! 1063: } else if (httpSession != null) {
! 1064: httpSession.setLastAccessedTime();
! 1065: if (!httpSession.isValid()) {
! 1066: httpSession = new JigsawHttpSession(getSessionContext(),
! 1067: servletContext,
! 1068: createCookie());
! 1069: response.addCookie(httpSession.getCookie());
! 1070: }
! 1071: }
! 1072: return httpSession;
1.19 bmahe 1073: }
1074:
1.42 bmahe 1075: /**
1076: * Gets the current valid session associated with this request.
1.74 ! ylafon 1077: *
1.42 bmahe 1078: * @return the session associated with this request.
1079: */
1080: public HttpSession getSession() {
1.74 ! ylafon 1081: return getSession(true);
1.42 bmahe 1082: }
1083:
1.33 bmahe 1084: protected String getCookieName() {
1.74 ! ylafon 1085: ObservableProperties props =
! 1086: request.getClient().getServer().getProperties();
! 1087: return props.getString(ServletProps.SERVLET_COOKIE_NAME,
! 1088: ServletProps.DEFAULT_COOKIE_NAME);
1.33 bmahe 1089: }
1090:
1.19 bmahe 1091: protected Cookie createCookie() {
1.74 ! ylafon 1092: ObservableProperties props =
! 1093: request.getClient().getServer().getProperties();
! 1094: String name = props.getString(ServletProps.SERVLET_COOKIE_NAME,
! 1095: ServletProps.DEFAULT_COOKIE_NAME);
! 1096: String path = props.getString(ServletProps.SERVLET_COOKIE_PATH,
! 1097: "/");
! 1098: String domain = props.getString(ServletProps.SERVLET_COOKIE_DOMAIN,
! 1099: null);
! 1100: String comment = props.getString(ServletProps.SERVLET_COOKIE_COMMENT,
! 1101: null);
! 1102: int maxage = props.getInteger(ServletProps.SERVLET_COOKIE_MAXAGE,
! 1103: -1);
! 1104: boolean secure = props.getBoolean(ServletProps.SERVLET_COOKIE_SECURE,
! 1105: isSecure());
! 1106:
! 1107: Cookie cookie = new Cookie(name, null);
! 1108: cookie.setPath(path);
! 1109: cookie.setMaxAge(maxage);
! 1110: if ((comment != null) && (comment.length() > 0))
! 1111: cookie.setComment(comment);
! 1112: if ((domain != null) && (domain.length() > 0))
! 1113: cookie.setDomain(domain);
! 1114: cookie.setSecure(secure);
! 1115: return cookie;
1.19 bmahe 1116: }
1117:
1118: protected HttpSession getSession(String sessionId) {
1.74 ! ylafon 1119: if (sessionId != null)
! 1120: return getSessionContext().getSession(sessionId);
! 1121: return null;
1.18 bmahe 1122: }
1.57 ylafon 1123:
1.25 bmahe 1124: /**
1.74 ! ylafon 1125: * Checks whether this request is associated with a session that is valid
1.25 bmahe 1126: * in the current session context. If it is not valid, the requested
1.74 ! ylafon 1127: * session will never be returned from the getSession method.
! 1128: *
! 1129: * @return true if this request is assocated with a session that is valid
! 1130: * in the current session context.
1.25 bmahe 1131: */
1.18 bmahe 1132: public boolean isRequestedSessionIdValid() {
1.74 ! ylafon 1133: JigsawHttpSession session = (JigsawHttpSession)
! 1134: getSession(getRequestedSessionId());
! 1135: if (session == null)
! 1136: return false;
! 1137: return (session.isValid());
1.18 bmahe 1138: }
1139:
1.25 bmahe 1140: /**
1.74 ! ylafon 1141: * Checks whether the session id specified by this request came in as
! 1142: * a cookie. (The requested session may not be one returned by the
1.25 bmahe 1143: * getSession method.)
1.74 ! ylafon 1144: *
! 1145: * @return true if the session id specified by this request came
! 1146: * in as a cookie; false otherwise
1.25 bmahe 1147: */
1.18 bmahe 1148: public boolean isRequestedSessionIdFromCookie() {
1.74 ! ylafon 1149: return (getRequestedSessionIdFromCookie() != null);
1.18 bmahe 1150: }
1151:
1.25 bmahe 1152: /**
1.74 ! ylafon 1153: * Checks whether the session id specified by this request came in as
! 1154: * part of the URL. (The requested session may not be the one returned
1.25 bmahe 1155: * by the getSession method.)
1.74 ! ylafon 1156: *
! 1157: * @return true if the session id specified by the request for this
! 1158: * session came in as part of the URL; false otherwise
1.42 bmahe 1159: * @deprecated since jsdk2.1
1.25 bmahe 1160: */
1.18 bmahe 1161: public boolean isRequestedSessionIdFromUrl() {
1.74 ! ylafon 1162: return (getRequestedSessionIdFromURL() != null);
1.18 bmahe 1163: }
1164:
1.42 bmahe 1165: /**
1.74 ! ylafon 1166: * Checks whether the session id specified by this request came in as
! 1167: * part of the URL. (The requested session may not be the one returned
1.42 bmahe 1168: * by the getSession method.)
1.74 ! ylafon 1169: *
! 1170: * @return true if the session id specified by the request for this
! 1171: * session came in as part of the URL; false otherwise
1.42 bmahe 1172: */
1173: public boolean isRequestedSessionIdFromURL() {
1.74 ! ylafon 1174: return (getRequestedSessionIdFromURL() != null);
1.42 bmahe 1175: }
1176:
1.18 bmahe 1177: protected BufferedReader reader = null;
1.25 bmahe 1178:
1179: /**
1.74 ! ylafon 1180: * Returns a buffered reader for reading text in the request body.
1.25 bmahe 1181: * This translates character set encodings as appropriate.
1.74 ! ylafon 1182: *
! 1183: * @throws UnsupportedEncodingException if the character set encoding
! 1184: * is unsupported, so the text can't be correctly decoded.
! 1185: * @throws IllegalStateException if getInputStream has been called on
! 1186: * this same request.
! 1187: * @throws IOException on other I/O related errors.
! 1188: * @see JigsawHttpServletRequest#getInputStream
1.25 bmahe 1189: */
1.18 bmahe 1190: public BufferedReader getReader()
1.74 ! ylafon 1191: throws IOException {
! 1192: if (stream_state == INPUT_STREAM_USED)
! 1193: throw new IllegalStateException("Input Stream used");
! 1194: stream_state = STREAM_READER_USED;
! 1195: if (reader == null) {
! 1196: InputStream is = getJigsawInputStream();
! 1197: String enc = getCharacterEncoding();
! 1198: if (enc != null) {
! 1199: InputStreamReader isr = null;
! 1200: try {
! 1201: isr = new InputStreamReader(is, enc);
! 1202: } catch (UnsupportedEncodingException ex) {
! 1203: // not a valid encoding, skip it
! 1204: isr = null;
! 1205: }
! 1206: if (isr != null)
! 1207: reader = new BufferedReader(isr);
! 1208: else
! 1209: reader = new BufferedReader(new InputStreamReader(is));
! 1210: } else {
! 1211: reader = new BufferedReader(new InputStreamReader(is));
! 1212: }
! 1213: }
! 1214: return reader;
1.42 bmahe 1215: }
1216:
1217: /**
1.47 bmahe 1218: * Get the wrapped Jigsaw Request.
1.74 ! ylafon 1219: *
1.47 bmahe 1220: * @return the request
1.42 bmahe 1221: */
1222: protected Request getRequest() {
1.74 ! ylafon 1223: return request;
1.19 bmahe 1224: }
1225:
1.74 ! ylafon 1226: JigsawHttpServletRequest(Servlet servlet,
! 1227: JigsawServletContext servletContext,
! 1228: Request request,
! 1229: JigsawHttpServletResponse response,
! 1230: JigsawHttpSessionContext sessionContext) {
! 1231: this.servlet = servlet;
! 1232: this.servletContext = servletContext;
! 1233: this.request = request;
! 1234: this.response = response;
! 1235: this.sessionContext = sessionContext;
1.17 bmahe 1236: }
1237:
1.1 abaird 1238: }
Webmaster