1 16 package org.mortbay.jetty.servlet; 17 18 import java.io.IOException ; 19 import java.io.PrintWriter ; 20 import java.util.Collections ; 21 import java.util.Enumeration ; 22 import java.util.HashMap ; 23 import java.util.HashSet ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import java.util.Locale ; 27 import java.util.Map ; 28 29 import javax.servlet.RequestDispatcher ; 30 import javax.servlet.ServletException ; 31 import javax.servlet.ServletOutputStream ; 32 import javax.servlet.ServletRequest ; 33 import javax.servlet.ServletResponse ; 34 import javax.servlet.http.Cookie ; 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletRequestWrapper ; 37 import javax.servlet.http.HttpServletResponse ; 38 import javax.servlet.http.HttpServletResponseWrapper ; 39 import javax.servlet.http.HttpSession ; 40 41 import org.apache.commons.logging.Log; 42 import org.mortbay.log.LogFactory; 43 import org.mortbay.http.HttpConnection; 44 import org.mortbay.http.PathMap; 45 import org.mortbay.util.LazyList; 46 import org.mortbay.util.LogSupport; 47 import org.mortbay.util.MultiMap; 48 import org.mortbay.util.StringMap; 49 import org.mortbay.util.URI; 50 import org.mortbay.util.UrlEncoded; 51 import org.mortbay.util.WriterOutputStream; 52 53 54 59 public class Dispatcher implements RequestDispatcher 60 { 61 static Log log = LogFactory.getLog(Dispatcher.class); 62 63 64 65 66 public static final int __DEFAULT=0; 67 public static final int __REQUEST=1; 68 public static final int __FORWARD=2; 69 public static final int __INCLUDE=4; 70 public static final int __ERROR=8; 71 public static final int __ALL=15; 72 73 74 public final static String __INCLUDE_REQUEST_URI= "javax.servlet.include.request_uri"; 75 public final static String __INCLUDE_CONTEXT_PATH= "javax.servlet.include.context_path"; 76 public final static String __INCLUDE_SERVLET_PATH= "javax.servlet.include.servlet_path"; 77 public final static String __INCLUDE_PATH_INFO= "javax.servlet.include.path_info"; 78 public final static String __INCLUDE_QUERY_STRING= "javax.servlet.include.query_string"; 79 80 81 public final static String __FORWARD_REQUEST_URI= "javax.servlet.forward.request_uri"; 82 public final static String __FORWARD_CONTEXT_PATH= "javax.servlet.forward.context_path"; 83 public final static String __FORWARD_SERVLET_PATH= "javax.servlet.forward.servlet_path"; 84 public final static String __FORWARD_PATH_INFO= "javax.servlet.forward.path_info"; 85 public final static String __FORWARD_QUERY_STRING= "javax.servlet.forward.query_string"; 86 87 88 public final static StringMap __managedAttributes = new StringMap(); 89 static 90 { 91 __managedAttributes.put(__INCLUDE_REQUEST_URI,__INCLUDE_REQUEST_URI); 92 __managedAttributes.put(__INCLUDE_CONTEXT_PATH,__INCLUDE_CONTEXT_PATH); 93 __managedAttributes.put(__INCLUDE_SERVLET_PATH,__INCLUDE_SERVLET_PATH); 94 __managedAttributes.put(__INCLUDE_PATH_INFO,__INCLUDE_PATH_INFO); 95 __managedAttributes.put(__INCLUDE_QUERY_STRING,__INCLUDE_QUERY_STRING); 96 97 __managedAttributes.put(__FORWARD_REQUEST_URI,__FORWARD_REQUEST_URI); 98 __managedAttributes.put(__FORWARD_CONTEXT_PATH,__FORWARD_CONTEXT_PATH); 99 __managedAttributes.put(__FORWARD_SERVLET_PATH,__FORWARD_SERVLET_PATH); 100 __managedAttributes.put(__FORWARD_PATH_INFO,__FORWARD_PATH_INFO); 101 __managedAttributes.put(__FORWARD_QUERY_STRING,__FORWARD_QUERY_STRING); 102 } 103 104 ServletHandler _servletHandler; 105 ServletHolder _holder=null; 106 String _pathSpec; 107 String _uriInContext; 108 String _pathInContext; 109 String _query; 110 111 112 113 121 Dispatcher(ServletHandler servletHandler, 122 String uriInContext, 123 String pathInContext, 124 String query, 125 Map.Entry entry) 126 throws IllegalStateException 127 { 128 if(log.isDebugEnabled())log.debug("Dispatcher for "+servletHandler+","+uriInContext+","+query); 129 130 _servletHandler=servletHandler; 131 _uriInContext=uriInContext; 132 _pathInContext=pathInContext; 133 _query=query; 134 _pathSpec=(String )entry.getKey(); 135 _holder = (ServletHolder)entry.getValue(); 136 } 137 138 139 143 Dispatcher(ServletHandler servletHandler,String name) 144 throws IllegalStateException 145 { 146 _servletHandler=servletHandler; 147 _holder=_servletHandler.getServletHolder(name); 148 if (_holder==null) 149 throw new IllegalStateException ("No named servlet handler in context"); 150 } 151 152 153 public boolean isNamed() 154 { 155 return _pathInContext==null; 156 } 157 158 159 public void include(ServletRequest servletRequest, 160 ServletResponse servletResponse) 161 throws ServletException , IOException 162 { 163 dispatch(servletRequest,servletResponse,Dispatcher.__INCLUDE); 164 } 165 166 167 public void forward(ServletRequest servletRequest, 168 ServletResponse servletResponse) 169 throws ServletException ,IOException 170 { 171 dispatch(servletRequest,servletResponse,Dispatcher.__FORWARD); 172 } 173 174 175 void error(ServletRequest servletRequest, 176 ServletResponse servletResponse) 177 throws ServletException ,IOException 178 { 179 dispatch(servletRequest,servletResponse,Dispatcher.__ERROR); 180 } 181 182 183 void dispatch(ServletRequest servletRequest, 184 ServletResponse servletResponse, 185 int type) 186 throws ServletException ,IOException 187 { 188 HttpServletRequest httpServletRequest=(HttpServletRequest )servletRequest; 189 HttpServletResponse httpServletResponse=(HttpServletResponse )servletResponse; 190 191 HttpConnection httpConnection= 192 _servletHandler.getHttpContext().getHttpConnection(); 193 ServletHttpRequest servletHttpRequest= 194 (ServletHttpRequest)httpConnection.getRequest().getWrapper(); 195 196 DispatcherRequest request = new DispatcherRequest(httpServletRequest, 198 servletHttpRequest, 199 type); 200 DispatcherResponse response = new DispatcherResponse(request, 201 httpServletResponse); 202 203 if (type==Dispatcher.__FORWARD) 204 servletResponse.resetBuffer(); 205 206 String query=_query; 208 MultiMap parameters=null; 209 if (query!=null) 210 { 211 Map old_params = httpServletRequest.getParameterMap(); 212 213 parameters=new MultiMap(); 215 UrlEncoded.decodeTo(query,parameters,request.getCharacterEncoding()); 216 217 if (old_params!=null && old_params.size()>0) 218 { 219 Iterator iter = old_params.entrySet().iterator(); 221 while (iter.hasNext()) 222 { 223 Map.Entry entry = (Map.Entry )iter.next(); 224 String name=(String )entry.getKey(); 225 String [] values=(String [])entry.getValue(); 226 for (int i=0;i<values.length;i++) 227 parameters.add(name, values[i]); 228 } 229 } 230 231 request.setParameters(parameters); 232 233 String old_query=httpServletRequest.getQueryString(); 234 if (old_query!=null) 235 request.setQuery(query+"&"+old_query); 236 else 237 request.setQuery(query); 238 } 239 240 Object old_scope = null; 241 try 242 { 243 if (request.crossContext()) 244 { 245 old_scope= 247 _servletHandler.getHttpContext() 248 .enterContextScope(httpConnection.getRequest(),httpConnection.getResponse()); 249 } 250 251 if (isNamed()) 252 { 253 if (_servletHandler instanceof WebApplicationHandler) 255 { 256 JSR154Filter filter = ((WebApplicationHandler)_servletHandler).getJsr154Filter(); 257 if (filter!=null && filter.isUnwrappedDispatchSupported()) 258 { 259 filter.setDispatch(request, response); 260 _servletHandler.dispatch(null,httpServletRequest,httpServletResponse,_holder, type); 261 } 262 else 263 _servletHandler.dispatch(null,request,response,_holder, type); 264 } 265 else 266 _servletHandler.dispatch(null,request,response,_holder, type); 267 } 268 else 269 { 270 request.setPaths(_servletHandler.getHttpContext().getContextPath(), 272 PathMap.pathMatch(_pathSpec,_pathInContext), 273 PathMap.pathInfo(_pathSpec,_pathInContext)); 274 275 276 if (_servletHandler instanceof WebApplicationHandler) 278 { 279 JSR154Filter filter = ((WebApplicationHandler)_servletHandler).getJsr154Filter(); 280 if (filter!=null && filter.isUnwrappedDispatchSupported()) 281 { 282 filter.setDispatch(request, response); 283 _servletHandler.dispatch(_pathInContext,httpServletRequest,httpServletResponse,_holder, type); 284 } 285 else 286 _servletHandler.dispatch(_pathInContext,request,response,_holder, type); 287 } 288 else 289 _servletHandler.dispatch(_pathInContext,request,response,_holder, type); 290 291 292 if (type!=Dispatcher.__INCLUDE) 293 response.close(); 294 else if (response.isFlushNeeded()) 295 response.flushBuffer(); 296 } 297 } 298 finally 299 { 300 if (request.crossContext()) 302 _servletHandler.getHttpContext() 303 .leaveContextScope(httpConnection.getRequest(), 304 httpConnection.getResponse(), 305 old_scope); 306 } 307 } 308 309 310 public String toString() 311 { 312 return "Dispatcher["+_pathSpec+","+_holder+"]"; 313 } 314 315 316 317 319 public static int type(String type) 320 { 321 if ("request".equalsIgnoreCase(type)) 322 return __REQUEST; 323 if ("forward".equalsIgnoreCase(type)) 324 return __FORWARD; 325 if ("include".equalsIgnoreCase(type)) 326 return __INCLUDE; 327 if ("error".equalsIgnoreCase(type)) 328 return __ERROR; 329 throw new IllegalArgumentException (type); 330 } 331 332 333 334 335 336 class DispatcherRequest extends HttpServletRequestWrapper 337 { 338 DispatcherResponse _response; 339 int _filterType; 340 String _contextPath; 341 String _servletPath; 342 String _pathInfo; 343 MultiMap _parameters; 344 HashMap _attributes; 345 boolean _xContext; 346 HttpSession _xSession; 347 ServletHttpRequest _servletHttpRequest; 348 String _query; 349 350 351 DispatcherRequest(HttpServletRequest httpServletRequest, 352 ServletHttpRequest servletHttpRequest, 353 int filterType) 354 { 355 super(httpServletRequest); 356 _servletHttpRequest=servletHttpRequest; 357 _filterType=filterType; 358 359 _xContext= 361 servletHttpRequest.getServletHandler()!=_servletHandler; 362 if (_xContext) 363 { 364 HttpSession session=httpServletRequest.getSession(false); 366 String session_id=(session==null) 367 ?httpServletRequest.getRequestedSessionId() 368 :session.getId(); 369 370 if (session_id!=null) 372 { 373 _xSession=_servletHandler.getHttpSession(session_id); 374 if (_xSession!=null) 375 ((SessionManager.Session)_xSession).access(); 376 } 377 } 378 } 379 380 381 boolean crossContext() 382 { 383 return _xContext; 384 } 385 386 387 void setPaths(String cp,String sp, String pi) 388 { 389 _contextPath = (cp.length()==1 && cp.charAt(0)=='/')?"":cp; 390 _servletPath=sp; 391 _pathInfo=pi; 392 } 393 394 395 void setQuery(String q) 396 { 397 this._query=q; 398 } 399 400 401 int getFilterType() 402 { 403 return _filterType; 404 } 405 406 407 String getPathInContext() 408 { 409 if (_pathInContext!=null) 410 return _pathInContext; 411 else 412 return URI.addPaths(getServletPath(),getPathInfo()); 413 } 414 415 416 public String getRequestURI() 417 { 418 if (_filterType==Dispatcher.__INCLUDE || isNamed()) 419 return super.getRequestURI(); 420 return URI.addPaths(_contextPath,_uriInContext); 421 } 422 423 424 public StringBuffer getRequestURL() 425 { 426 if (_filterType==Dispatcher.__INCLUDE || isNamed()) 427 return super.getRequestURL(); 428 StringBuffer buf = getRootURL(); 429 if (_contextPath.length()>0) 430 buf.append(_contextPath); 431 buf.append(_uriInContext); 432 return buf; 433 } 434 435 436 437 public String getPathTranslated() 438 { 439 String info=getPathInfo(); 440 if (info==null) 441 return null; 442 return getRealPath(info); 443 } 444 445 446 StringBuffer getRootURL() 447 { 448 StringBuffer buf = super.getRequestURL(); 449 int d=3; 450 for (int i=0;i<buf.length();i++) 451 { 452 if (buf.charAt(i)=='/' && --d==0) 453 { 454 buf.setLength(i); 455 break; 456 } 457 } 458 return buf; 459 } 460 461 462 public String getContextPath() 463 { 464 return(_filterType==Dispatcher.__INCLUDE||isNamed())?super.getContextPath():_contextPath; 465 } 466 467 468 public String getServletPath() 469 { 470 return(_filterType==Dispatcher.__INCLUDE||isNamed())?super.getServletPath():_servletPath; 471 } 472 473 474 public String getPathInfo() 475 { 476 return(_filterType==Dispatcher.__INCLUDE||isNamed())?super.getPathInfo():_pathInfo; 477 } 478 479 480 public String getQueryString() 481 { 482 if (this._query==null) 483 return super.getQueryString(); 484 return this._query; 485 } 486 487 488 void setParameters(MultiMap parameters) 489 { 490 _parameters=parameters; 491 } 492 493 494 public Enumeration getParameterNames() 495 { 496 if (_parameters==null) 497 return super.getParameterNames(); 498 499 return Collections.enumeration(_parameters.keySet()); 500 } 501 502 503 public String getParameter(String name) 504 { 505 if (_parameters==null) 506 return super.getParameter(name); 507 return (String )_parameters.getValue(name,0); 508 } 509 510 511 public String [] getParameterValues(String name) 512 { 513 if (_parameters==null) 514 return super.getParameterValues(name); 515 List l =_parameters.getValues(name); 516 if (l==null) 517 return null; 518 return (String [])l.toArray(new String [l.size()]); 519 } 520 521 522 public Map getParameterMap() 523 { 524 if (_parameters==null) 525 return super.getParameterMap(); 526 527 return _parameters.toStringArrayMap(); 528 } 529 530 531 public void setAttribute(String name, Object value) 532 { 533 if (__managedAttributes.containsKey(name)) 534 { 535 if (_attributes==null) 536 _attributes=new HashMap (3); 537 _attributes.put(name,value); 538 } 539 else 540 super.setAttribute(name,value); 541 } 542 543 544 public Object getAttribute(String name) 545 { 546 if (_attributes!=null && _attributes.containsKey(name)) 547 return _attributes.get(name); 548 549 if (_filterType==Dispatcher.__INCLUDE && !isNamed()) 550 { 551 if (name.equals(__INCLUDE_PATH_INFO)) return _pathInfo; 552 if (name.equals(__INCLUDE_REQUEST_URI)) return URI.addPaths(_contextPath,_uriInContext); 553 if (name.equals(__INCLUDE_SERVLET_PATH)) return _servletPath; 554 if (name.equals(__INCLUDE_CONTEXT_PATH)) return _contextPath; 555 if (name.equals(__INCLUDE_QUERY_STRING)) return Dispatcher.this._query; 556 } 557 else 558 { 559 if (name.equals(__INCLUDE_PATH_INFO)) return null; 560 if (name.equals(__INCLUDE_REQUEST_URI)) return null; 561 if (name.equals(__INCLUDE_SERVLET_PATH)) return null; 562 if (name.equals(__INCLUDE_CONTEXT_PATH)) return null; 563 if (name.equals(__INCLUDE_QUERY_STRING)) return null; 564 } 565 566 if (_filterType!=Dispatcher.__INCLUDE && !isNamed()) 567 { 568 if (name.equals(__FORWARD_PATH_INFO)) 569 return _servletHttpRequest.getPathInfo(); 570 if (name.equals(__FORWARD_REQUEST_URI)) 571 return _servletHttpRequest.getRequestURI(); 572 if (name.equals(__FORWARD_SERVLET_PATH)) 573 return _servletHttpRequest.getServletPath(); 574 if (name.equals(__FORWARD_CONTEXT_PATH)) 575 return _servletHttpRequest.getContextPath(); 576 if (name.equals(__FORWARD_QUERY_STRING)) 577 return _servletHttpRequest.getQueryString(); 578 } 579 580 return super.getAttribute(name); 581 } 582 583 584 public Enumeration getAttributeNames() 585 { 586 HashSet set=new HashSet (); 587 Enumeration e=super.getAttributeNames(); 588 while (e.hasMoreElements()) 589 set.add(e.nextElement()); 590 591 if (_filterType==Dispatcher.__INCLUDE && !isNamed()) 592 { 593 if (_pathInfo!=null) 594 set.add(__INCLUDE_PATH_INFO); 595 else 596 set.remove(__INCLUDE_PATH_INFO); 597 set.add(__INCLUDE_REQUEST_URI); 598 set.add(__INCLUDE_SERVLET_PATH); 599 set.add(__INCLUDE_CONTEXT_PATH); 600 if (Dispatcher.this._query!=null) 601 set.add(__INCLUDE_QUERY_STRING); 602 else 603 set.remove(__INCLUDE_QUERY_STRING); 604 605 } 606 else 607 { 608 set.remove(__INCLUDE_PATH_INFO); 609 set.remove(__INCLUDE_REQUEST_URI); 610 set.remove(__INCLUDE_SERVLET_PATH); 611 set.remove(__INCLUDE_CONTEXT_PATH); 612 set.remove(__INCLUDE_QUERY_STRING); 613 } 614 615 if (_filterType!=Dispatcher.__INCLUDE && !isNamed()) 616 { 617 if (_servletHttpRequest.getPathInfo()!=null) 618 set.add(__FORWARD_PATH_INFO); 619 else 620 set.remove(__FORWARD_PATH_INFO); 621 622 set.add(__FORWARD_REQUEST_URI); 623 set.add(__FORWARD_SERVLET_PATH); 624 set.add(__FORWARD_CONTEXT_PATH); 625 if (_servletHttpRequest.getQueryString()!=null) 626 set.add(__FORWARD_QUERY_STRING); 627 else 628 set.remove(__FORWARD_QUERY_STRING); 629 } 630 631 if (_attributes!=null) 632 set.addAll(_attributes.keySet()); 633 634 return Collections.enumeration(set); 635 } 636 637 638 642 public HttpSession getSession(boolean create) 643 { 644 if (_xContext) 645 { 646 if (_xSession==null) 647 { 648 if (getAttribute("org.mortbay.jetty.servlet.Dispatcher.shared_session") != null) 649 _xSession= super.getSession(create); 650 else 651 { 652 log.debug("Ctx dispatch session"); 653 654 String rsid=getRequestedSessionId(); 655 if (rsid==null) 656 { 657 HttpSession session=super.getSession(false); 658 if (session!=null) 659 rsid=session.getId(); 660 } 661 _xSession=_servletHandler.getHttpSession(rsid); 662 if (create && _xSession==null) 663 { 664 _xSession=_servletHandler.newHttpSession(this); 665 Cookie cookie = _servletHandler.getSessionManager().getSessionCookie(_xSession, isSecure()); 666 if (cookie!=null) 667 _servletHttpRequest.getHttpRequest().getHttpResponse().addSetCookie(cookie); 668 } 669 } 670 671 } 672 return _xSession; 673 } 674 else 675 return super.getSession(create); 676 } 677 678 679 public boolean isRequestedSessionIdValid() 680 { 681 if (_xContext) 682 { 683 String requestedSessionid = super.getRequestedSessionId(); 684 if (requestedSessionid != null) 685 { 686 HttpSession session = getSession(false); 687 if (session != null) 688 { 689 return ((AbstractSessionManager.Session)session).isValid() && requestedSessionid.equals(session.getId()); 690 } 691 } 692 return false; 693 } 694 else 695 { 696 return super.isRequestedSessionIdValid(); 697 } 698 } 699 700 701 public HttpSession getSession() 702 { 703 return getSession(true); 704 } 705 706 707 public String getRealPath(String path) 708 { 709 return _servletHandler.getServletContext().getRealPath(path); 710 } 711 712 713 public RequestDispatcher getRequestDispatcher(String url) 714 { 715 if (url == null) 716 return null; 717 718 if (!url.startsWith("/")) 719 { 720 String relTo=URI.addPaths(getServletPath(),getPathInfo()); 721 int slash=relTo.lastIndexOf("/"); 722 if (slash>1) 723 relTo=relTo.substring(0,slash+1); 724 else 725 relTo="/"; 726 url=URI.addPaths(relTo,url); 727 } 728 729 return _servletHandler.getServletContext().getRequestDispatcher(url); 730 } 731 732 public String getMethod() 733 { 734 if (this._filterType==Dispatcher.__ERROR) 735 return org.mortbay.http.HttpRequest.__GET; 736 return super.getMethod(); 737 } 738 } 739 740 741 742 743 class DispatcherResponse extends HttpServletResponseWrapper 744 { 745 DispatcherRequest _request; 746 private ServletOutputStream _out=null; 747 private PrintWriter _writer=null; 748 private boolean _flushNeeded=false; 749 private boolean _include; 750 751 752 DispatcherResponse(DispatcherRequest request, HttpServletResponse response) 753 { 754 super(response); 755 _request=request; 756 request._response=this; 757 _include=_request._filterType==Dispatcher.__INCLUDE; 758 759 } 760 761 762 public ServletOutputStream getOutputStream() 763 throws IOException 764 { 765 if (_writer!=null) 766 throw new IllegalStateException ("getWriter called"); 767 768 if (_out==null) 769 { 770 try {_out=super.getOutputStream();} 771 catch(IllegalStateException e) 772 { 773 LogSupport.ignore(log,e); 774 _flushNeeded=true; 775 _out=new ServletOut(new WriterOutputStream(super.getWriter())); 776 } 777 } 778 779 if (_include) 780 _out=new DontCloseServletOut(_out); 781 782 return _out; 783 } 784 785 786 public PrintWriter getWriter() 787 throws IOException 788 { 789 if (_out!=null) 790 throw new IllegalStateException ("getOutputStream called"); 791 792 if (_writer==null) 793 { 794 try{_writer=super.getWriter();} 795 catch(IllegalStateException e) 796 { 797 LogSupport.ignore(log, e); 798 _flushNeeded=true; 799 _writer = new ServletWriter(super.getOutputStream(), 800 getCharacterEncoding()); 801 } 802 } 803 804 if (_include) 805 _writer=new DontCloseWriter(_writer); 806 return _writer; 807 } 808 809 810 boolean isFlushNeeded() 811 { 812 return _flushNeeded; 813 } 814 815 816 public void flushBuffer() 817 throws IOException 818 { 819 if (_writer!=null) 820 _writer.flush(); 821 if (_out!=null) 822 _out.flush(); 823 super.flushBuffer(); 824 } 825 826 827 public void close() 828 throws IOException 829 { 830 if (_writer!=null) 831 _writer.close(); 832 if (_out!=null) 833 _out.close(); 834 } 835 836 837 public void setLocale(Locale locale) 838 { 839 if (!_include) super.setLocale(locale); 840 } 841 842 843 public void sendError(int status, String message) 844 throws IOException 845 { 846 if (_request._filterType!=Dispatcher.__ERROR && !_include) 847 super.sendError(status,message); 848 } 849 850 851 public void sendError(int status) 852 throws IOException 853 { 854 if (_request._filterType!=Dispatcher.__ERROR && !_include) 855 super.sendError(status); 856 } 857 858 859 public void sendRedirect(String url) 860 throws IOException 861 { 862 if (!_include) 863 { 864 if (!url.startsWith("http:/")&&!url.startsWith("https:/")) 865 { 866 StringBuffer buf = _request.getRootURL(); 867 868 if (url.startsWith("/")) 869 buf.append(URI.canonicalPath(url)); 870 else 871 buf.append(URI.canonicalPath(URI.addPaths(URI.parentPath(_request.getRequestURI()),url))); 872 url=buf.toString(); 873 } 874 875 super.sendRedirect(url); 876 } 877 } 878 879 880 public void setDateHeader(String name, long value) 881 { 882 if (!_include) super.setDateHeader(name,value); 883 } 884 885 886 public void setHeader(String name, String value) 887 { 888 if (!_include) super.setHeader(name,value); 889 } 890 891 892 public void setIntHeader(String name, int value) 893 { 894 if (!_include) super.setIntHeader(name,value); 895 } 896 897 898 public void addHeader(String name, String value) 899 { 900 if (!_include) super.addHeader(name,value); 901 } 902 903 904 public void addDateHeader(String name, long value) 905 { 906 if (!_include) super.addDateHeader(name,value); 907 } 908 909 910 public void addIntHeader(String name, int value) 911 { 912 if (!_include) super.addIntHeader(name,value); 913 } 914 915 916 public void setStatus(int status) 917 { 918 if (_request._filterType!=Dispatcher.__ERROR && !_include) 919 super.setStatus(status); 920 } 921 922 923 935 public void setStatus(int status, String message) 936 { 937 if (_request._filterType!=Dispatcher.__ERROR && !_include) 938 super.setStatus(status,message); 939 } 940 941 942 public void setContentLength(int len) 943 { 944 if (!_include) super.setContentLength(len); 945 } 946 947 948 public void setContentType(String contentType) 949 { 950 if (!_include) super.setContentType(contentType); 951 } 952 953 954 public void addCookie(Cookie cookie) 955 { 956 if (!_include) super.addCookie(cookie); 957 } 958 } 959 960 961 962 963 964 private class DontCloseWriter extends PrintWriter 965 { 966 DontCloseWriter(PrintWriter writer) 967 { 968 super(writer); 969 } 970 971 public void close() 972 {} 973 } 974 975 976 977 978 private class DontCloseServletOut extends ServletOut 979 { 980 DontCloseServletOut(ServletOutputStream output) 981 { 982 super(output); 983 } 984 985 public void close() 986 throws IOException 987 {} 988 } 989 }; 990 | Popular Tags |