Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CA9039085 for ; Wed, 19 Oct 2011 17:57:20 +0000 (UTC) Received: (qmail 65422 invoked by uid 500); 19 Oct 2011 17:57:17 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 65222 invoked by uid 500); 19 Oct 2011 17:57:17 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 65212 invoked by uid 99); 19 Oct 2011 17:57:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Oct 2011 17:57:17 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [169.229.218.144] (HELO cm03fe.IST.Berkeley.EDU) (169.229.218.144) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Oct 2011 17:57:07 +0000 Received: from doean-289-034.lib.berkeley.edu ([128.32.99.171] helo=[127.0.0.1]) by cm03fe.ist.berkeley.edu with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (auth plain:gmills@library.berkeley.edu) (envelope-from ) id 1RGaNh-0002V7-A9 for users@tomcat.apache.org; Wed, 19 Oct 2011 10:56:45 -0700 Message-ID: <4E9F0F50.5060102@library.berkeley.edu> Date: Wed, 19 Oct 2011 10:56:32 -0700 From: Garey Mills Reply-To: gmills@library.berkeley.edu User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: users@tomcat.apache.org Subject: question about inter-webapp communication Content-Type: multipart/alternative; boundary="------------090804060205020008080105" X-Virus-Checked: Checked by ClamAV on apache.org --------------090804060205020008080105 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello - Tomcat 7.0.8 on RHEL6. I have two webapps, one accessed at /webapp_one and one at /webapp_two. My question has to do with how to include output from /webapp_two in the output of /webapp_one. I want to use /webapp_one as an authentication front end for /webapp_two, since /webapp_two is a large, complex web app and I want to do authentication filtering on patterns in the query string. My scheme is to analyze the request URL in the body of /webapp_one. If it should be protected, rewrite it by adding a flag into the URI, so that it can be caught by my authentication filter in the web.xml, and redirect it back to /webapp_one. If it does not have to be protected, or if it has been protected by my filter, wrap the request so that it looks like a request to /webapp_two, get a RequestDispatcher from /webapp_two's context, and 'include' the output from /webapp_two in the response from /webapp_one. The problem is that this is not working, and I believe that the problem is in how I am getting /webapp_two's ServletContext, or in how I am referring to the servlet in /webapp_two's context, since I am not seeing any activity from /webapp_two in the logs. Here are the particulars: * I have 'crossContext=true' set in /webapp_one's context * Here is my request wrapper public class MyRequestWrapper extends HttpServletRequestWrapper { String queryString = null; String uri = null; String contextPath = null; String pathTranslated = null; public GSRequestWrapper(HttpServletRequest req) { super(req); } public void setRequestURI(String newUri) { uri = newUri; } public String getRequestURI() { return uri; } public void setContextPath(String cp) { contextPath = cp; } public String getContextPath() { return contextPath; } public void setPathTranslated(String pt) { pathTranslated = pt; } public String getPathTranslated() { return pathTranslated; } public StringBuffer getRequestURL() { StringBuffer sb = new StringBuffer(); sb.append(uri + "?" + queryString); return sb; } } * Here is the code I use to create the wrapper MyRequestWrapper myReq = new MyRequestWrapper(req); myReq.setRequestURI(req.getRequestURI().replaceFirst("webapp_one", "webapp_two")); myReq.setContextPath(req.getContextPath().replaceFirst("webapp_one", "webapp_two")); myReq.setPathTranslated(req.getPathTranslated().replaceFirst("webapp_one", "webapp_two")); ServletContext twoContext = sc.getContext("/webapp_two"); * In /webapp_two, the url-pattern intercepted is '/*', so this is how I am trying to create the RequestDispatcher RequestDispatcher rd = twoContext.getRequestDispatcher("/"); Trying all this out, I see that the RequestDispatcher I am creating is not null, but I am not seeing any activity in /webapp_two, and the page returned is blank. Am I making a mistake in referring to the context of /webapp_two, or in how I am creating my request wrapper, or in how I am referring to the servlet in /webapp_two? Garey Mills Library Systems Office UC Berkeley --------------090804060205020008080105--