Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-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 4C78F10B7D for ; Thu, 14 Nov 2013 05:07:52 +0000 (UTC) Received: (qmail 74412 invoked by uid 500); 14 Nov 2013 05:07:50 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 74076 invoked by uid 500); 14 Nov 2013 05:07:47 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 74068 invoked by uid 99); 14 Nov 2013 05:07:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2013 05:07:45 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of maralc@gmail.com designates 74.125.82.52 as permitted sender) Received: from [74.125.82.52] (HELO mail-wg0-f52.google.com) (74.125.82.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2013 05:07:38 +0000 Received: by mail-wg0-f52.google.com with SMTP id z12so1356453wgg.7 for ; Wed, 13 Nov 2013 21:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6Ip7L1k/sqoysgztICh4T84QLJVUj2HmECNQjkSKrQ8=; b=ezkfnK2R7r3C4x0qaESfkLIq59oIzZ+Ii5fFhvoFrQ8gq6FjhBUx5ygnnuaaM5xlB/ paMeUSYMKr5A28yhhsF42FA7H9Ta4s2vJcwRifraCqT36aS+uTjiINJGDSXtnh9OCiHw xkKDAuVRhh4TKJp2vJ0/ma3Pf9NaN2CQ8yZo+ZghrB4zqrhBIMHlYC26TsQf/70eUEsp q/vArZGZk0gW3WnvzxC1iAFWj18Jb/+GfGdk4FqJGckIP58vRyDP6nx08JuxWNIAlVH4 0SaOrxB573TjYzoiODEGJS97Ph3JODWH08RSyZN74UCnZSoLaPOrnQVFcROEl4PjK8pF s1Ag== MIME-Version: 1.0 X-Received: by 10.194.174.36 with SMTP id bp4mr33460767wjc.7.1384405638350; Wed, 13 Nov 2013 21:07:18 -0800 (PST) Received: by 10.223.78.72 with HTTP; Wed, 13 Nov 2013 21:07:18 -0800 (PST) In-Reply-To: <52835401.6080701@gmail.com> References: <52835401.6080701@gmail.com> Date: Thu, 14 Nov 2013 18:07:18 +1300 Message-ID: Subject: Re: Fowarding to jsp from CXF From: Marcelo Alcantara To: users@cxf.apache.org Content-Type: multipart/alternative; boundary=089e0141a0ae4c8eb604eb1c0ec0 X-Virus-Checked: Checked by ClamAV on apache.org --089e0141a0ae4c8eb604eb1c0ec0 Content-Type: text/plain; charset=ISO-8859-1 Hi Sergey, Thanks a lot for the very detailed response. I tried your second option but could not make it work. That's the message I get: [qtp1721979929-14] WARN org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor - No root resource matching request path /auth/oauth2/WEB-INF/jsp/login_full.jsp has been found, Relative Path: /WEB-INF/jsp/login_full.jsp. Please enable FINE/TRACE log level for more details. Is there any aditional configuration in the web.xml that is needed to make it works? Thanks Marcelo -- Marcelo Alcantara Senior Developer/Architect -------------------------------------------------------- maralc@gmail.com +64 21 0612324 On Wed, Nov 13, 2013 at 11:27 PM, Sergey Beryozkin wrote: > Hi > > On 13/11/13 07:04, Marcelo Alcantara wrote: > >> Hi >> >> I need to redirect to a jsp that is inside WEB-INF from a CXF/Jetty >> started >> server. >> >> How can I redirect from inside a rest service to a jsp that is inside >> WEB-INF/jsp? >> >> I tried doing a simple servlet forward but it always use the app context >> regardless of weather the path starts with '/' or not. >> >> I also saw the documentation but in my case the jsp is not related at all >> with any entity (it's a login page). >> >> > Assuming your work with CXF 2.7.7, then what you can do is to use JAX-RS > 2.0 Pre-Matching ContainerRequestFilter which will block the request with a > ready Response, this Response would set a media type text/html and set the > 'marker' entity either an enum (ex, LOGIN_REQUIRED) or some empty class > like LoginRequired, using enums can be cheaper, and then configure CXF > RequestDispatcherProvider as suggested here: > > http://cxf.apache.org/docs/jax-rs-redirection.html#JAX-RSRedirection- > WithRequestDispatcherProvider, check the example on configuring it with > enums if you chose to work with enums. > > Note, setting a 'marker' entity in Response is needed because otherwise > RequestDispatcherProvider, being JAX-RS MessageBodyWriter, won't be > activated. > > However you can avoid using RequestDispatcherProvider by doing something > like this in your custom ContainerRequestFilter (vaguely referred to in > http://cxf.apache.org/docs/jax-rs-redirection.html#JAX-RSRedirection- > CustomRedirection): > > 1. inject "@Context HttpServletRequest request"; > 2. PhaseInterceptorChain.getCurrentMessage().put(AbstractHTTPDestination.REQUEST_REDIRECTED, > true); > 3. Use HttpServletRequest to get to RequestDispatcher and forward the > request to the chosen jsp resource > > This will work fine too. > > Finally, if you have CXFServlet using a wildcard url pattern, then you'd > need to further restrict it to ensure the above redirects do not get > captured by the same servlet > > HTH, Sergey > > > Thanks in advance. >> >> Marcelo >> >> > --089e0141a0ae4c8eb604eb1c0ec0--