KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > template > jsp > WebManRequest


1 package de.webman.template.jsp;
2
3 import javax.servlet.*;
4 import javax.servlet.http.*;
5 import java.util.*;
6 import java.io.*;
7 /**
8     Implementierung des HttpRequest fuer die Abarbeitung der jsp Templates
9  * @author $Author: alex $
10  * @version $Revision: 1.5 $
11  */

12 public class WebManRequest implements HttpServletRequest
13 {
14     private static final String JavaDoc ATTRIBUTE = "wm-data";
15         
16     private Hashtable attributes = new Hashtable();
17     
18     private HttpServletRequest originalRequest;
19     
20     private WebManSession session;
21     
22     private ServletContext context;
23     
24     public WebManRequest(ServletContext _context)
25     {
26         context = _context;
27     }
28     
29     /*
30     public WebManRequest(Object _data, HttpServletRequest _originalRequest)
31     {
32         attributes.put(ATTRIBUTE, _data);
33         originalRequest = _originalRequest;
34     }
35     */

36     public void setData(Object JavaDoc data)
37     {
38         attributes.put(ATTRIBUTE, data);
39     }
40     
41     public void setOriginalRequest(HttpServletRequest _originalRequest)
42     {
43         originalRequest = _originalRequest;
44     }
45     /**
46      * Returns an input stream for reading binary data in the request body.
47      *
48      * @see getReader
49      * @exception IllegalStateException if getReader has been
50      * called on this same request.
51      * @exception IOException on other I/O related errors.
52      */

53     public ServletInputStream getInputStream() throws IOException
54     {
55         return null; // ???
56
}
57
58     /**
59      * Returns a string containing the lone value of the specified
60      * parameter, or null if the parameter does not exist. For example,
61      * in an HTTP servlet this method would return the value of the
62      * specified query string parameter. Servlet writers should use
63      * this method only when they are sure that there is only one value
64      * for the parameter. If the parameter has (or could have)
65      * multiple values, servlet writers should use
66      * getParameterValues. If a multiple valued parameter name is
67      * passed as an argument, the return value is implementation
68      * dependent.
69      *
70      * @see #getParameterValues
71      *
72      * @param name the name of the parameter whose value is required.
73      */

74     public String JavaDoc getParameter(String JavaDoc name)
75     {
76         // ausfuellen !!
77
return "";
78     }
79
80     /**
81      * Returns the values of the specified parameter for the request as
82      * an array of strings, or null if the named parameter does not
83      * exist. For example, in an HTTP servlet this method would return
84      * the values of the specified query string or posted form as an
85      * array of strings.
86      *
87      * @param name the name of the parameter whose value is required.
88      * @see javax.servlet.ServletRequest#getParameter
89      */

90     public String JavaDoc[] getParameterValues(String JavaDoc name)
91     {
92         return null;
93     }
94
95     /**
96      * Returns the parameter names for this request as an enumeration
97      * of strings, or an empty enumeration if there are no parameters
98      * or the input stream is empty. The input stream would be empty
99      * if all the data had been read from the stream returned by the
100      * method getInputStream.
101      */

102     public Enumeration getParameterNames()
103     {
104         return null;
105     }
106
107     /**
108      * Returns the value of the named attribute of the request, or
109      * null if the attribute does not exist. This method allows
110      * access to request information not already provided by the other
111      * methods in this interface. Attribute names should follow the
112      * same convention as package names.
113      * @param name the name of the attribute whose value is required
114      */

115     public Object JavaDoc getAttribute(String JavaDoc name)
116     {
117         return attributes.get(name);
118     }
119     
120     public java.lang.String JavaDoc getContextPath()
121     {
122         if (originalRequest != null)
123             return originalRequest.getContextPath();
124         return "";
125     }
126
127     public java.util.Enumeration JavaDoc getHeaders(java.lang.String JavaDoc name)
128     {
129         if (originalRequest != null)
130             return originalRequest.getHeaders(name);
131         return null;
132     }
133     
134     public boolean isUserInRole(java.lang.String JavaDoc role)
135     {
136         return false;
137     }
138     
139     public boolean isRequestedSessionIdFromURL()
140     {
141         if (originalRequest != null)
142             return originalRequest.isRequestedSessionIdFromURL();
143         return false;
144     }
145     
146     public java.security.Principal JavaDoc getUserPrincipal()
147     {
148         return null;
149     }
150     
151     public java.util.Locale JavaDoc getLocale()
152     {
153         if (originalRequest != null)
154             return originalRequest.getLocale();
155         return null;
156     }
157     
158     public boolean isSecure()
159     {
160         return false;
161     }
162     
163     public void removeAttribute(java.lang.String JavaDoc name)
164     {}
165     
166     public void setAttribute(java.lang.String JavaDoc name, java.lang.Object JavaDoc o)
167     {}
168     
169     public RequestDispatcher getRequestDispatcher(java.lang.String JavaDoc path)
170     {
171         if (originalRequest != null)
172             return originalRequest.getRequestDispatcher(path);
173         return null;
174     }
175     
176     public java.util.Enumeration JavaDoc getLocales()
177     {
178         return null;
179     }
180     public java.util.Enumeration JavaDoc getAttributeNames()
181     {
182         return attributes.keys();
183     }
184     
185     /**
186      * Returns a buffered reader for reading text in the request body.
187      * This translates character set encodings as appropriate.
188      *
189      * @see getInputStream
190      *
191      * @exception UnsupportedEncodingException if the character set encoding
192      * is unsupported, so the text can't be correctly decoded.
193      * @exception IllegalStateException if getInputStream has been
194      * called on this same request.
195      * @exception IOException on other I/O related errors.
196      */

197     public BufferedReader getReader () throws IOException
198     {
199         return null;
200     }
201
202     /**
203      * Returns the character set encoding for the input of this request.
204      */

205     public String JavaDoc getCharacterEncoding ()
206     {
207         if (originalRequest != null)
208             return originalRequest.getCharacterEncoding();
209         return null;
210     }
211     
212     /**
213      * Gets the array of cookies found in this request.
214      *
215      * @return the array of cookies found in this request
216      */

217     public Cookie[] getCookies()
218     {
219         return null;
220     }
221
222     /**
223      * Gets the HTTP method (for example, GET, POST, PUT) with which
224      * this request was made. Same as the CGI variable REQUEST_METHOD.
225      *
226      * @return the HTTP method with which this request was made
227      */

228     public String JavaDoc getMethod()
229     {
230         if (originalRequest != null)
231             return originalRequest.getMethod();
232         return "POST";
233     }
234     /**
235      * Gets, from the first line of the HTTP request, the part of this
236      * request's URI that is to the left of any query string.
237      *
238      *
239      * @return this request's URI
240      */

241     public String JavaDoc getRequestURI()
242     {
243         if (originalRequest != null)
244             return originalRequest.getRequestURI();
245         return "";
246     }
247
248     /**
249         2.3
250         Overrides the name of the character encoding used in the body of this request.
251         This method must be called prior to reading request parameters or reading input using getReader()
252     */

253     public void setCharacterEncoding(java.lang.String JavaDoc env)
254                           throws java.io.UnsupportedEncodingException JavaDoc
255
256     {
257     }
258     
259     /**
260         2.3
261         Returns a java.util.Map of the parameters of this request.
262         Request parameters are extra information sent with the request.
263         For HTTP servlets, parameters are contained in the query string or posted form data.
264     */

265     public java.util.Map JavaDoc getParameterMap()
266     {
267         return null;
268     }
269
270     /**
271         2.3
272         Reconstructs the URL the client used to make the request.
273         The returned URL contains a protocol, server name, port number, and server path,
274         but it does not include query string parameters.
275         Because this method returns a StringBuffer, not a string, you can modify the URL easily,
276         for example, to append query parameters.
277         This method is useful for creating redirect messages and for reporting errors.
278     */

279     public java.lang.StringBuffer JavaDoc getRequestURL()
280     {
281         if (originalRequest != null)
282             return new StringBuffer JavaDoc("");
283         return new StringBuffer JavaDoc("");
284     }
285
286
287     /**
288      * Gets the part of this request's URI that refers to the servlet
289      * being invoked. Analogous to the CGI variable SCRIPT_NAME.
290      *
291      * @return the servlet being invoked, as contained in this
292      * request's URI
293      */

294     public String JavaDoc getServletPath()
295     {
296         if (originalRequest != null)
297             return originalRequest.getServletPath();
298         return "";
299     }
300
301     /**
302      * Gets any optional extra path information following the servlet
303      * path of this request's URI, but immediately preceding its query
304      * string. Same as the CGI variable PATH_INFO.
305      *
306      * @return the optional path information following the servlet
307      * path, but before the query string, in this request's URI; null
308      * if this request's URI contains no extra path information
309      */

310     public String JavaDoc getPathInfo()
311     {
312         if (originalRequest != null)
313             return originalRequest.getPathInfo();
314         return null;
315     }
316
317     /**
318      * Gets any optional extra path information following the servlet
319      * path of this request's URI, but immediately preceding its query
320      * string, and translates it to a real path. Similar to the CGI
321      * variable PATH_TRANSLATED
322      *
323      * @return extra path information translated to a real path or null
324      * if no extra path information is in the request's URI
325      */

326     public String JavaDoc getPathTranslated()
327     {
328         if (originalRequest != null)
329             return originalRequest.getPathTranslated();
330         return null;
331     }
332
333     /**
334      * Gets any query string that is part of the HTTP request URI.
335      * Same as the CGI variable QUERY_STRING.
336      *
337      * @return query string that is part of this request's URI, or null
338      * if it contains no query string
339      */

340     public String JavaDoc getQueryString()
341     {
342         if (originalRequest != null)
343             return originalRequest.getQueryString();
344         return null;
345     }
346
347     /**
348      * Gets the name of the user making this request. The user name is
349      * set with HTTP authentication. Whether the user name will
350      * continue to be sent with each subsequent communication is
351      * browser-dependent. Same as the CGI variable REMOTE_USER.
352      *
353      * @return the name of the user making this request, or null if not
354      * known.
355      */

356     public String JavaDoc getRemoteUser()
357     {
358         if (originalRequest != null)
359             return originalRequest.getRemoteUser();
360         return null;
361     }
362
363     /**
364      * Gets the authentication scheme of this request. Same as the CGI
365      * variable AUTH_TYPE.
366      *
367      * @return this request's authentication scheme, or null if none.
368      */

369     public String JavaDoc getAuthType()
370     {
371         return null;
372     }
373
374     /**
375      * Gets the value of the requested header field of this request.
376      * The case of the header field name is ignored.
377      *
378      * @param name the String containing the name of the requested
379      * header field
380      * @return the value of the requested header field, or null if not
381      * known.
382      */

383     public String JavaDoc getHeader(String JavaDoc name)
384     {
385         return null;
386     }
387
388     /**
389      * Gets the value of the specified integer header field of this
390      * request. The case of the header field name is ignored. If the
391      * header can't be converted to an integer, the method throws a
392      * NumberFormatException.
393      *
394      * @param name the String containing the name of the requested
395      * header field
396      * @return the value of the requested header field, or -1 if not
397      * found.
398      */

399     public int getIntHeader(String JavaDoc name)
400     {
401         return -1;
402     }
403
404     /**
405      * Gets the value of the requested date header field of this
406      * request. If the header can't be converted to a date, the method
407      * throws an IllegalArgumentException. The case of the header
408      * field name is ignored.
409      *
410      * @param name the String containing the name of the requested
411      * header field
412      * @return the value the requested date header field, or -1 if not
413      * found.
414      */

415     public long getDateHeader(String JavaDoc name)
416     {
417         return -1;
418     }
419
420     /**
421      * Gets the header names for this request.
422      *
423      * @return an enumeration of strings representing the header names
424      * for this request. Some server implementations do not allow
425      * headers to be accessed in this way, in which case this method
426      * will return null.
427      */

428     public Enumeration getHeaderNames()
429     {
430         return null;
431     }
432
433     /**
434      * Gets the current valid session associated with this request, if
435      * create is false or, if necessary, creates a new session for the
436      * request, if create is true.
437      *
438      *
439      * @return the session associated with this request or null if
440      * create was false and no valid session is associated
441      * with this request.
442      */

443     public HttpSession getSession (boolean create)
444     {
445         if (session == null && create)
446         {
447             session = new WebManSession(context);
448         }
449         return session;
450     }
451     
452     public HttpSession getSession()
453     {
454         return getSession(true);
455     }
456     
457    
458     /**
459      * Gets the session id specified with this request. This may
460      * differ from the actual session id. For example, if the request
461      * specified an id for an invalid session, then this will get a new
462      * session with a new id.
463      *
464      * @return the session id specified by this request, or null if the
465      * request did not specify a session id
466      *
467      * @see #isRequestedSessionIdValid */

468     public String JavaDoc getRequestedSessionId ()
469     {
470         return null;
471     }
472
473     /**
474      * Checks whether this request is associated with a session that
475      * is valid in the current session context. If it is not valid,
476      * the requested session will never be returned from the
477      * <code>getSession</code> method.
478      *
479      * @return true if this request is assocated with a session that is
480      * valid in the current session context.
481      *
482      * @see #getRequestedSessionId
483      * @see javax.servlet.http.HttpSessionContext
484      * @see #getSession
485      */

486     public boolean isRequestedSessionIdValid ()
487     {
488         return false;
489     }
490
491     /**
492      * Checks whether the session id specified by this request came in
493      * as a cookie. (The requested session may not be one returned by
494      * the <code>getSession</code> method.)
495      *
496      * @return true if the session id specified by this request came in
497      * as a cookie; false otherwise
498      *
499      * @see #getSession
500      */

501     public boolean isRequestedSessionIdFromCookie ()
502     {
503         return false;
504     }
505
506     /**
507      * Checks whether the session id specified by this request came in
508      * as part of the URL. (The requested session may not be the one
509      * returned by the <code>getSession</code> method.)
510      *
511      * @return true if the session id specified by the request for this
512      * session came in as part of the URL; false otherwise
513      *
514      * @see #getSession
515         @deprecated
516      */

517     public boolean isRequestedSessionIdFromUrl ()
518     {
519         return false;
520     }
521     /**
522      * Returns the size of the request entity data, or -1 if not known.
523      * Same as the CGI variable CONTENT_LENGTH.
524      */

525     public int getContentLength()
526     {
527         return -1; // Vielleicht aendern ?
528
}
529
530     /**
531      * Returns the Internet Media Type of the request entity data, or
532      * null if not known. Same as the CGI variable CONTENT_TYPE.
533      */

534     public String JavaDoc getContentType()
535     {
536         if (originalRequest != null)
537             return originalRequest.getContentType();
538         return null;
539     }
540
541     /**
542      * Returns the protocol and version of the request as a string of
543      * the form <code>&lt;protocol&gt;/&lt;major version&gt;.&lt;minor
544      * version&gt</code>. Same as the CGI variable SERVER_PROTOCOL.
545      */

546     public String JavaDoc getProtocol()
547     {
548         if (originalRequest != null)
549             return originalRequest.getProtocol();
550         return null;
551     }
552
553     /**
554      * Returns the scheme of the URL used in this request, for example
555      * "http", "https", or "ftp". Different schemes have different
556      * rules for constructing URLs, as noted in RFC 1738. The URL used
557      * to create a request may be reconstructed using this scheme, the
558      * server name and port, and additional information such as URIs.
559      */

560     public String JavaDoc getScheme()
561     {
562         if (originalRequest != null)
563             return originalRequest.getScheme();
564         return null;
565     }
566
567     /**
568      * Returns the host name of the server that received the request.
569      * Same as the CGI variable SERVER_NAME.
570      */

571     public String JavaDoc getServerName()
572     {
573         if (originalRequest != null)
574             return originalRequest.getServerName();
575         return null;
576     }
577
578     /**
579      * Returns the port number on which this request was received.
580      * Same as the CGI variable SERVER_PORT.
581      */

582     public int getServerPort()
583     {
584         if (originalRequest != null)
585             return originalRequest.getServerPort();
586         return 0;
587     }
588
589     /**
590      * Returns the IP address of the agent that sent the request.
591      * Same as the CGI variable REMOTE_ADDR.
592      */

593     public String JavaDoc getRemoteAddr()
594     {
595         return null;
596     }
597
598     /**
599      * Returns the fully qualified host name of the agent that sent the
600      * request. Same as the CGI variable REMOTE_HOST.
601      */

602     public String JavaDoc getRemoteHost()
603     {
604         return null;
605     }
606
607     /**
608      * Applies alias rules to the specified virtual path and returns
609      * the corresponding real path, or null if the translation can not
610      * be performed for any reason. For example, an HTTP servlet would
611      * resolve the path using the virtual docroot, if virtual hosting
612      * is enabled, and with the default docroot otherwise. Calling
613      * this method with the string "/" as an argument returns the
614      * document root.
615      *
616      * @param path the virtual path to be translated to a real path
617      @deprecated
618      */

619     public String JavaDoc getRealPath(String JavaDoc path)
620     {
621         if (originalRequest != null)
622             return originalRequest.getRealPath(path);
623         return null;
624     }
625
626
627 }
628
Popular Tags