0

I have a jsf app which has an index page as default, configured on web.xml:

    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>

So, if I navigate to the address http://myIp:8080/myContext/ it redirects automatically to the address http://myIp:8080/myContext/faces/index.xhtml

I want to use this address in a way which allows the user to insert any text after the context address and the server automatically redirects to desired index, configured on welcome-file-list.

Some input examples that I want to redirect directly to my index page

http://myIp:8080/myContext/blahblahblah

http://myIp:8080/myContext/blahblahblah.jpg

http://myIp:8080/myContext/ (this is the only one working actually)

Obs.: I'm using glassfish, if the web container matters

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
marionmaiden
  • 3,250
  • 8
  • 33
  • 50
  • 1
    `http://myIp:8080/myContext/blahblahblah.jpg` or `http://myIp:8080/myContext/blahblahblah` could be valid paths for your web application, under what circumstances should you redirect them to the index page? That should trigger a 404 error per se. Unless you want to secure your application, then it should show the login view and once you're logged in try to redirect to the firstly requested resource. – Aritz Sep 19 '14 at 17:18
  • May my 404 page be the index? This way I could redirect these invalid paths always to the index page – marionmaiden Sep 19 '14 at 17:26
  • 1
    Usually popular sites have a pretty page where they show a 404 error. You could instead redirect to your index page, of course. Spanish BBC site, as an example, does it to a `categories` page: http://www.bbc.es/fsdafsd. Check out [this](http://stackoverflow.com/a/7066536/1199132) link to show different views depending on the error code. – Aritz Sep 19 '14 at 17:32

1 Answers1

0

As proposed by @xtreme-biker, I used the 404 error to trigger the index page.

This is the code I added to the web.xml Thus, any address I insert in the browser, it redirects me to the index page.

<error-page>
    <error-code>404</error-code>
    <location>faces/index.xhtml</location>
</error-page>
marionmaiden
  • 3,250
  • 8
  • 33
  • 50