tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Behrens" <>
Subject Forwarding from within a Servlet
Date Tue, 29 Apr 2003 13:34:26 GMT
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:

            RequestDispatcher rd =
request.getRequestDispatcher(getPathToRoot(request) + TIMEOUT_URL);
            try {
            }catch (Exception e) {
                if(DEBUG)out.println("accessControll.accessDenied() <BR>"+e);

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 RequestDispatcher however
doesn't forward to the right page but instead ignores all but the pagename.

It be very thankfull for any help & comment


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message