Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EEAA11147D for ; Wed, 30 Jul 2014 10:47:39 +0000 (UTC) Received: (qmail 43840 invoked by uid 500); 30 Jul 2014 10:47:39 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 43773 invoked by uid 500); 30 Jul 2014 10:47:39 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 43761 invoked by uid 99); 30 Jul 2014 10:47:39 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jul 2014 10:47:39 +0000 Date: Wed, 30 Jul 2014 10:47:39 +0000 (UTC) From: "Victor Bashurov (JIRA)" To: dev@felix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FELIX-4589) Problem with forwarding from one servlet to another MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FELIX-4589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14079163#comment-14079163 ] Victor Bashurov commented on FELIX-4589: ---------------------------------------- RequestDispatcher rd = req.getRequestDispatcher(ForwardServlet.SERVLET_ALIAS); works for the sample from bitbucket [https://bitbucket.org/vbashur/diff/src] but doesn't work for my other code. Unfortunately, cannot provide code snippet. The workaround with using request object to obtain request dispatcher cannot be applied in a cross-context modules. For example Bundle 1 - /servletbridge/service - /servletbridge/forward Bundle 2 - /servletmain Within req.getRequestDispatcher it's okay to forward requests between servlets in bundle 1, but bundle 2 is unreachable. To forward to Bundle 2 we need to perform: Servlet Context sc = getServetContext().getContext("/servletmain"); RequestDispatcher rd = sc.getRequestDispatcher("/"); rd.include(request, response); // welcome to the endless loop > Problem with forwarding from one servlet to another > --------------------------------------------------- > > Key: FELIX-4589 > URL: https://issues.apache.org/jira/browse/FELIX-4589 > Project: Felix > Issue Type: Bug > Components: HTTP Service > Affects Versions: http-2.3.0 > Reporter: Victor Bashurov > > Like in an issue FELIX-2774 (https://issues.apache.org/jira/browse/FELIX-2774) I'd like to have a several servlet bunles installed with embedded OSGI framework. I'm using servlet bridge for request's management between sevlets bundles. In order to pass the information between servlets I want to use request dispatcher to forward (or include) http queries from one servlet to another. > Even when I have two servlets registered in one bundle I cannot make a forwarding from one servlet to another. > ServiceTracker > httpService.registerServlet(TestServlet.SERVLET_ALIAS, new TestServlet("Test servlet"), null, null); httpService.registerServlet(ForwardServlet.SERVLET_ALIAS, new ForwardServlet("Forward servlet"), null, null); > Trying to do the following in a TestServlet doGet method will cause error: > RequestDispatcher rd = getServletContext().getRequestDispatcher(ForwardServlet.SERVLET_ALIAS); > rd.forward(req, res); > For org.apache.felix.http.bridge-2.0.2.jar error will be NullPointerException on 'rd' variable, for version 2.2.0 the same, but for version 2.3.0 it's going to be endless loop and stackoverflow error. > More code about the problem here: https://bitbucket.org/vbashur/diff/src (servletbundle project) -- This message was sent by Atlassian JIRA (v6.2#6252)