Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 7122 invoked from network); 29 Apr 2003 16:17:24 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 29 Apr 2003 16:17:24 -0000 Received: (qmail 26949 invoked by uid 97); 29 Apr 2003 16:19:23 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@nagoya.betaversion.org Received: (qmail 26942 invoked from network); 29 Apr 2003 16:19:23 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 29 Apr 2003 16:19:23 -0000 Received: (qmail 72339 invoked by uid 500); 29 Apr 2003 14:32:36 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 72283 invoked from network); 29 Apr 2003 14:32:34 -0000 Received: from unknown (HELO mustang.mpi.com) (63.244.250.132) by daedalus.apache.org with SMTP; 29 Apr 2003 14:32:34 -0000 Received: from thunderbolt.mpi.com (thunderbolt.mpi.com [199.93.192.55]) by mustang.mpi.com (Switch-2.2.6/Switch-2.2.6) with ESMTP id h3TEWYp01993 for ; Tue, 29 Apr 2003 10:32:34 -0400 (EDT) Received: from US-VS1.corp.mpi.com (us-be2.corp.mpi.com [199.93.195.21]) by thunderbolt.mpi.com (Switch-3.0.4/Switch-3.0.0) with ESMTP id h3TEVsVM010459 for ; Tue, 29 Apr 2003 10:32:34 -0400 (EDT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: Forwarding from within a Servlet Date: Tue, 29 Apr 2003 10:32:31 -0400 Message-ID: <9C5166762F311146951505C6790A9CF858E942@US-VS1.corp.mpi.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Forwarding from within a Servlet Thread-Index: AcMOW1m4KRqmD++YS3ybl6UrzTAiDwAAImnw From: "Shapira, Yoav" To: "Tomcat Users List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Howdy, The request dispatcher expects an argument starting with a /, not ../.= The argument is relative to the context root, aka the docBase of your webapp. So if your timeout.html page is at the docbase, call rd.include("/timeout.html"). Also consider using one of the following alternatives: - RequestDispatcher.forward to a servlet that handles unauthorized use= rs and/or timeouts - Throwing a specific exception, e.g. UnauthorizedUserException, which= you have mapped (via an tag in web.xml) to a handler. Th= is way you don't have to the redirection manually, as the container will = do it for you automatically. Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Jan Behrens [mailto:jan@diekleinedomain.de] >Sent: Tuesday, April 29, 2003 9:34 AM >To: Tomcat Users List >Subject: Forwarding from within a Servlet > >Hi List, > >I have a servlet that is supposed to controll the access of app-users= on a >"per keyword" base. Certain jsp's in my app include that servlet on load >and >pass a string specifying the calling pagename. The servlet then gets = my >user-object out of the request-session and checks whether the particular >user >is allowed to access or not. If he is, the servlet just writes a comment in >to >the stream and thats it. If however the user is not allowed to access= that >particular resource, I want to redirect the user to a different page within >my >app. If the session expired and therefore no user-object could be found, I >would like to forward the user to a different page... > >My problem is that I am quite new to servlets (have worked with jsp's= only >so >far) and I am not sure how to go about forwarding from within my servlet. I >have tried the following: > >[snip] > if(DEBUG)out.println("
logOutUser
"); > RequestDispatcher rd =3D >request.getRequestDispatcher(getPathToRoot(request) + TIMEOUT_URL); > try { > rd.include(request,response); > out.close(); > }catch (Exception e) { > if(DEBUG)out.println("accessControll.accessDenied() >
"+e); > out.close(); > } >[/snip] > >getPathToRoot() basically takes the request.getHeader("referer") and >extracts >the number of "/", minus those used in the hostname and returns a string >containing "../" for each "/" found and TIMEOUT_URL contains the complete >path >to the resource from document-root. >The url build out of those is correct in itself, the RequestDispatche= r >however >doesn't forward to the right page but instead ignores all but the pagename. > >It be very thankfull for any help & comment > >Jan > > >---------------------------------------------------------------------= >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org This e-mail, including any attachments, is a confidential business com= munication, and may contain information that is confidential, propriet= ary and/or privileged. This e-mail is intended only for the individua= l(s) to whom it is addressed, and may not be saved, copied, printed, d= isclosed or used by anyone else. If you are not the(an) intended reci= pient, please immediately delete this e-mail from your computer system= and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org