2

I have "/pages/index.xhtml" page. The problem is when i run the application, this index page name doesn't appears at address bar.

It only shows http://localhost:8080/myApplication/. What I want to see is http://localhost:8080/myApplication/pages/index.xhtml

Is there any solution?

here is my welcome file from web.xml

<welcome-file-list>
    <welcome-file>pages/index.xhtml</welcome-file>
</welcome-file-list>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Turgut Dsfadfa
  • 775
  • 6
  • 20
  • 42

1 Answers1

4

You need to send a redirect from / to /pages/index.xhtml. Easiest is to use a real index file with a meta refresh header for this.

First create a /index.xhtml file as follows:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Dummy homepage</title>
    <meta http-equiv="refresh" content="0; url=pages/index.xhtml" />
  </head>
</html>

Then change your <welcome-file> as follows:

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

This also instantly fixes your bad way of using <welcome-file>. It's not supposed to specify the "home page", but it's supposed to specify the folder's own file which needs to be served when a folder such as / or /foo/ is requested in URL instead of a file.

See also

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555