Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the start page of my web project?

When i created a new project in eclipse, it automatically created for me an index.jsp page, i don't want the start page to be a .jsp, i want it to be a .xhtml This is what i did at the 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 page myStartPage.xhtml as the first page when i run the project in localhost.

How should i modify this for the browser to display for me the start page. Also i dont want to use any url-pattern. Is that mandatory?(I tried removing that tag, but it did not build).

like image 491
javing Avatar asked May 25 '11 09:05

javing


2 Answers

Try this servlet mapping:

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

This works in Glassfish 3.

like image 147
McDowell Avatar answered Sep 29 '22 13:09

McDowell


As far as I know always the index.jsp will be shown. You can add a redirect to the index.jsp:

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

But there might be a nicer solution.

like image 20
morja Avatar answered Sep 29 '22 11:09

morja