1
votes

Should the welcome file mentioned in welcome file list tag always be physically present? i.e. jsp, html etc. Or can it be a URL pattern?

I defined a welcome file list in the web.xml as:

<welcome-file-list>  
    <welcome-file>/home</welcome-file>  
</welcome-file-list>

/home downloads a JSON file from the server to display on the browser. But whenever I start the application, it does not take me to the following page: http://localhost:8080/myapp/home. Instead it always goes to http://localhost:8080/myapp/ only. Please advise what am I doing wrong.

1

1 Answers

1
votes

it does need to have a physical file on your webapp folder for a welcome file to be found even if some kind of controller will treat the request, for example, if you have a JSF app and the FacesServlet only handles requests of type *.faces on your app you should place an empty file called home.faces under your webapp folder, so it can be correctly mapped, on your case I guess the issue is slightly different, you want to fetch data from the server side and display it on the browser when user first lands on your app, so what you can do is actually:

  1. Create an HTML called home.html as your welcome file with an empty div as a placeholder for your data.

  2. Use a Javascript library or do an AJAX call to fetch the JSON from the server side

  3. If the result call is OK, render the placeholder DIV with data fetched from server.