0

I have a welcome page defined as follows in web.xml

<welcome-file-list>
    <welcome-file>templates/Template.jsf</welcome-file>
  </welcome-file-list>

and the context root for the project is TestProject. for the first time when i load the project the url is localhost:8080/TestProject. I have a button in the home page named "HOME" on click of which should redirect to home page from any other page. Now the problem is on click of this button, it redirects but the url becomes localhost:8080/TestProject/templates/Template.jsf. how to clocak this?

the html code for button is as follws

Home

Pallavi
  • 79
  • 1
  • 6

1 Answers1

1

It look like that you misunderstood the meaning of <welcome-file>. It is not intented to represent the URL of the home page. It is intented to represent the sole filename (excluding any physical folders! but allowing a virtual suffix mapping pattern in case you're using it like /faces/*) of the file which should be served up by the container when a folder is been requested like /, or /foo/, or /bar/baz/, etc. The container will then check if the folder contains the specified welcome file and then forward the request to it, otherwise display a 404.

I strongly recommend to keep it simple:

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

and have an index.xhtml in the root folder and if necessary also other folders. Then, to open the context root without the filename specified, just use

<a href="#{request.contextPath}/">Home</a>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555