How to change the start page of my web project?

When I created a new project in eclipse, it automatically created an index.jsp page for me, I don’t want the start page to be .jsp, I want it to be .xhtml This is what I did in web.xml:

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>myStartPage.xhtml</welcome-file>
</welcome-file-list>
</web-app> 

The above code does not allow me to see the myStartPage.xhtml page as the first page when starting the project in the local host.

How do I change this for the browser to display the start page for me. Also I do not want to use any url template. Is this mandatory? (I tried to remove this tag, but it was not created).

+5
source share
2 answers

Try mapping the servlet:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

Glassfish 3.

+5

, index.jsp. index.jsp:

<% response.sendRedirect("myStartPage.xhtml"); %>

.

+1

All Articles