Rest and Static Content

View: New views
6 Messages — Rating Filter:   Alert me  

Rest and Static Content

by Monde Hans :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,
I am new to rest.
I have been trying to expose our application  with rest. The problem is that
if we map CXF to /* it tries to serve3 the static content as well.
The only work around is being specific. Like map each service' path and
methods that it exposes.

@Path("/say")
public class SayHello{

@GET
@Path("/hello")
public String hello(){
 return "Hello"
}

The mapping for this could be

<url-pattern>/say/hello<url-pattern>

and not

<url-pattern>/say/*<url-pattern>

How does one deal with this. Is the a way to stop CXF from serving static
content if <url-pattern>/*<url-pattern> is used?

Thank you.


--
I keep six honest serving-men (They taught me all I knew); Their names are
What and Why and When And How and Where and Who.

Re: Rest and Static Content

by Sergey Beryozkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

Can you please post a sample URI which results in a static content being served ?
thanks, Sergey


Monde Hans wrote:
Hi Guys,
I am new to rest.
I have been trying to expose our application  with rest. The problem is that
if we map CXF to /* it tries to serve3 the static content as well.
The only work around is being specific. Like map each service' path and
methods that it exposes.

@Path("/say")
public class SayHello{

@GET
@Path("/hello")
public String hello(){
 return "Hello"
}

The mapping for this could be

<url-pattern>/say/hello<url-pattern>

and not

<url-pattern>/say/*<url-pattern>

How does one deal with this. Is the a way to stop CXF from serving static
content if <url-pattern>/*<url-pattern> is used?

Thank you.


--
I keep six honest serving-men (They taught me all I knew); Their names are
What and Why and When And How and Where and Who.

Re: Rest and Static Content

by Monde Hans :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI sergy,
It turned out to be a configuration or mapping issue.

I mapped it to /services/* and that seems to have fixed the problem.

Monde Hans.

On Wed, Aug 5, 2009 at 10:29 AM, Sergey Beryozkin <sergey.beryozkin@...
> wrote:

>
> Hi
>
> Can you please post a sample URI which results in a static content being
> served ?
> thanks, Sergey
>
>
>
> Monde Hans wrote:
> >
> > Hi Guys,
> > I am new to rest.
> > I have been trying to expose our application  with rest. The problem is
> > that
> > if we map CXF to /* it tries to serve3 the static content as well.
> > The only work around is being specific. Like map each service' path and
> > methods that it exposes.
> >
> > @Path("/say")
> > public class SayHello{
> >
> > @GET
> > @Path("/hello")
> > public String hello(){
> >  return "Hello"
> > }
> >
> > The mapping for this could be
> >
> > <url-pattern>/say/hello<url-pattern>
> >
> > and not
> >
> > <url-pattern>/say/*<url-pattern>
> >
> > How does one deal with this. Is the a way to stop CXF from serving static
> > content if <url-pattern>/*<url-pattern> is used?
> >
> > Thank you.
> >
> >
> > --
> > I keep six honest serving-men (They taught me all I knew); Their names
> are
> > What and Why and When And How and Where and Who.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Rest-and-Static-Content-tp24792523p24822846.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>


--
I keep six honest serving-men (They taught me all I knew); Their names are
What and Why and When And How and Where and Who.

Re: Rest and Static Content

by Sergey Beryozkin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

ok, thanks for confirming it. "/services/*" restricts the space a bit but "/*" should also work...
As far as I understand your original problem, with "/*" requests like /index.html were unexpectedly picked up by CXFServlet... I think in case of Jetty one might be able to tackle it by configuring the stem matching, but I'll need to experiment...Another option is to actually provide a custom MessageObserver, something we did some time ago, which would itself serve the static content like index.html - I'll take a note of it and look a bit later

cheers, Sergey
 
Monde Hans wrote:
HI sergy,
It turned out to be a configuration or mapping issue.

I mapped it to /services/* and that seems to have fixed the problem.

Monde Hans.

On Wed, Aug 5, 2009 at 10:29 AM, Sergey Beryozkin <sergey.beryozkin@iona.com
> wrote:

>
> Hi
>
> Can you please post a sample URI which results in a static content being
> served ?
> thanks, Sergey
>
>
>
> Monde Hans wrote:
> >
> > Hi Guys,
> > I am new to rest.
> > I have been trying to expose our application  with rest. The problem is
> > that
> > if we map CXF to /* it tries to serve3 the static content as well.
> > The only work around is being specific. Like map each service' path and
> > methods that it exposes.
> >
> > @Path("/say")
> > public class SayHello{
> >
> > @GET
> > @Path("/hello")
> > public String hello(){
> >  return "Hello"
> > }
> >
> > The mapping for this could be
> >
> > <url-pattern>/say/hello<url-pattern>
> >
> > and not
> >
> > <url-pattern>/say/*<url-pattern>
> >
> > How does one deal with this. Is the a way to stop CXF from serving static
> > content if <url-pattern>/*<url-pattern> is used?
> >
> > Thank you.
> >
> >
> > --
> > I keep six honest serving-men (They taught me all I knew); Their names
> are
> > What and Why and When And How and Where and Who.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Rest-and-Static-Content-tp24792523p24822846.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>


--
I keep six honest serving-men (They taught me all I knew); Their names are
What and Why and When And How and Where and Who.

Re: Rest and Static Content

by dkulp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed August 5 2009 8:37:51 am Sergey Beryozkin wrote:

> Hi,
>
> ok, thanks for confirming it. "/services/*" restricts the space a bit but
> "/*" should also work...
> As far as I understand your original problem, with "/*" requests like
> /index.html were unexpectedly picked up by CXFServlet... I think in case of
> Jetty one might be able to tackle it by configuring the stem matching, but
> I'll need to experiment...Another option is to actually provide a custom
> MessageObserver, something we did some time ago, which would itself serve
> the static content like index.html - I'll take a note of it and look a bit
> later

Actually, I'm thinking more along the lines of updating the CXFServlet to feed
static content if a service is not registered on a particular URL (and it's
not the services list URL).    Thus, CXFServlet could always be registered on
/* and services and static content could "co-exist" together.   :-)

The problem with going down this route is if you start doing that, the next
person will come along and say "I have a jsp in there, can that co-exist?" and
so on and so on.   Once you start doing that, then most likely, the CXFServlet
should just not be used and we'd need to write an context listener thing that
would register very specific URL's for the services on the context and ONLY
those URL's.  

Dan




>
> cheers, Sergey
>
> Monde Hans wrote:
> > HI sergy,
> > It turned out to be a configuration or mapping issue.
> >
> > I mapped it to /services/* and that seems to have fixed the problem.
> >
> > Monde Hans.
> >
> > On Wed, Aug 5, 2009 at 10:29 AM, Sergey Beryozkin
> > <sergey.beryozkin@...
> >
> >> wrote:
> >>
> >>
> >> Hi
> >>
> >> Can you please post a sample URI which results in a static content being
> >> served ?
> >> thanks, Sergey
> >>
> >> Monde Hans wrote:
> >> > Hi Guys,
> >> > I am new to rest.
> >> > I have been trying to expose our application  with rest. The problem
> >> > is that
> >> > if we map CXF to /* it tries to serve3 the static content as well.
> >> > The only work around is being specific. Like map each service' path
> >> > and methods that it exposes.
> >> >
> >> > @Path("/say")
> >> > public class SayHello{
> >> >
> >> > @GET
> >> > @Path("/hello")
> >> > public String hello(){
> >> >  return "Hello"
> >> > }
> >> >
> >> > The mapping for this could be
> >> >
> >> > <url-pattern>/say/hello<url-pattern>
> >> >
> >> > and not
> >> >
> >> > <url-pattern>/say/*<url-pattern>
> >> >
> >> > How does one deal with this. Is the a way to stop CXF from serving
> >>
> >> static
> >>
> >> > content if <url-pattern>/*<url-pattern> is used?
> >> >
> >> > Thank you.
> >> >
> >> >
> >> > --
> >> > I keep six honest serving-men (They taught me all I knew); Their names
> >>
> >> are
> >>
> >> > What and Why and When And How and Where and Who.
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Rest-and-Static-Content-tp24792523p24822846.html
> >> Sent from the cxf-user mailing list archive at Nabble.com.

--
Daniel Kulp
dkulp@...
http://www.dankulp.com/blog

Re: Rest and Static Content

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I updated AbstractHTTPServlet to support redirects to other servlets/JSP, etc, and also optionally serve static resources,
CXFServlets with "/*" or "/custom/*" etc will be able to use the feature. Also, JAXRS RequestDispatcherProvider which can do the
same on the outbound chain has been added... I'll work on updating the docs later on

Sergey

----- Original Message -----
From: "Daniel Kulp" <dkulp@...>
To: <users@...>
Cc: "Sergey Beryozkin" <sergey.beryozkin@...>
Sent: Wednesday, August 05, 2009 3:54 PM
Subject: Re: Rest and Static Content


> On Wed August 5 2009 8:37:51 am Sergey Beryozkin wrote:
>> Hi,
>>
>> ok, thanks for confirming it. "/services/*" restricts the space a bit but
>> "/*" should also work...
>> As far as I understand your original problem, with "/*" requests like
>> /index.html were unexpectedly picked up by CXFServlet... I think in case of
>> Jetty one might be able to tackle it by configuring the stem matching, but
>> I'll need to experiment...Another option is to actually provide a custom
>> MessageObserver, something we did some time ago, which would itself serve
>> the static content like index.html - I'll take a note of it and look a bit
>> later
>
> Actually, I'm thinking more along the lines of updating the CXFServlet to feed
> static content if a service is not registered on a particular URL (and it's
> not the services list URL).    Thus, CXFServlet could always be registered on
> /* and services and static content could "co-exist" together.   :-)
>
> The problem with going down this route is if you start doing that, the next
> person will come along and say "I have a jsp in there, can that co-exist?" and
> so on and so on.   Once you start doing that, then most likely, the CXFServlet
> should just not be used and we'd need to write an context listener thing that
> would register very specific URL's for the services on the context and ONLY
> those URL's.
>
> Dan
>
>
>
>
>>
>> cheers, Sergey
>>
>> Monde Hans wrote:
>> > HI sergy,
>> > It turned out to be a configuration or mapping issue.
>> >
>> > I mapped it to /services/* and that seems to have fixed the problem.
>> >
>> > Monde Hans.
>> >
>> > On Wed, Aug 5, 2009 at 10:29 AM, Sergey Beryozkin
>> > <sergey.beryozkin@...
>> >
>> >> wrote:
>> >>
>> >>
>> >> Hi
>> >>
>> >> Can you please post a sample URI which results in a static content being
>> >> served ?
>> >> thanks, Sergey
>> >>
>> >> Monde Hans wrote:
>> >> > Hi Guys,
>> >> > I am new to rest.
>> >> > I have been trying to expose our application  with rest. The problem
>> >> > is that
>> >> > if we map CXF to /* it tries to serve3 the static content as well.
>> >> > The only work around is being specific. Like map each service' path
>> >> > and methods that it exposes.
>> >> >
>> >> > @Path("/say")
>> >> > public class SayHello{
>> >> >
>> >> > @GET
>> >> > @Path("/hello")
>> >> > public String hello(){
>> >> >  return "Hello"
>> >> > }
>> >> >
>> >> > The mapping for this could be
>> >> >
>> >> > <url-pattern>/say/hello<url-pattern>
>> >> >
>> >> > and not
>> >> >
>> >> > <url-pattern>/say/*<url-pattern>
>> >> >
>> >> > How does one deal with this. Is the a way to stop CXF from serving
>> >>
>> >> static
>> >>
>> >> > content if <url-pattern>/*<url-pattern> is used?
>> >> >
>> >> > Thank you.
>> >> >
>> >> >
>> >> > --
>> >> > I keep six honest serving-men (They taught me all I knew); Their names
>> >>
>> >> are
>> >>
>> >> > What and Why and When And How and Where and Who.
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Rest-and-Static-Content-tp24792523p24822846.html
>> >> Sent from the cxf-user mailing list archive at Nabble.com.
>
> --
> Daniel Kulp
> dkulp@...
> http://www.dankulp.com/blog