users@jax-rs-spec.java.net

[jax-rs-spec users] How to use JAX-RS on the root context (as an application wide MVC like request router / dispatcher)

From: Eran Medan <ehrann.mehdan_at_gmail.com>
Date: Wed, 12 Jun 2013 17:32:27 -0400

Dear Fellow JAX-RS users!

I'm trying to use JAX-RS as an MVC router, (to replace the need for
Spring's @RequestMapping)

To do so, I would like to have my JAX-RX Application start at the root
context, so my URLs will be

http://example.com*/*restfullPath <http://example.com/restfullPath>

and not:

http://example.com*/rest*/restfullPath<http://example.com/rest/restfullPath>

I switched my Application's annotation from this

@ApplicationPath("/rest/*")

to this

@ApplicationPath("/*")

All works well, but then it seems that it takes over serving files such as
/index.html or /index.jsp

Is there a way to run a JAX-RS on the root context but still have static /
JSP pages served?

Seems this was asked before <https://community.jboss.org/thread/199069> on
the JBOSS forum, but the solution is not really practical

(I asked this originally here:
http://stackoverflow.com/questions/10874188/jax-rs-application-on-the-root-context-how-can-it-be-done
but
the answer is too cumbersome and negates the benefit of using JAX-RS with
it's simplicity and elegant API)

The reason I'm asking is that this moved me back to Spring, which I rather
work without
In Spring @RequestMapping("/foo") works as well as
@RequestMapping("/foo/bar") and is absolute to the web app context, and can
serve JSP / HTML views without a problem.

In other words, I would expect to be able to map any request in JEE to any
resource, whether it's a JSON service, or a JSP view using the same easy to
use @Path annotation, can it be done?

Thanks,
Eran