1
votes

I'm building a RESTful Web Service using Jersey 2.22, and I have the following scenario:

When I try to make a request to a path that does not exist (it's not implemented in the resources package at all), it'll send back a 404 status, because the resource wasn't found (obviously).

If this situation happens, I'd like to forward to a default URI, like sending back to index.html, for example.

But since it's a resource that is not implemented yet, where should I write this validation? Should it be in my class that extends from Application/ResourceConfig and has the @ApplicationPath annotation ? Could anyone show me a way or a documentation, or even a post that it's explicitly said?

1

1 Answers

0
votes

You can handle 404 error code in your web.xml file -

    <error-page>
       <error-code>404</error-code>
       <location>/index.html</location>
    </error-page>

Details can be referred to How to specify the default error page in web.xml?