Reputation: 2343
Trying to redirect to admin.xhtml
page when I access http://localhost:8080/CSPPortal/index.html
. The root index.html
contains
<html><head><meta http-equiv="Refresh" content="0; URL=pages/admin.jsf"/></head></html>
The problem is the url keeps going back to login.jsf
which was declared in the index.html
before.
Tried: adding an empty index.jsf
page to the root folder. Tried mapping FacesServelet
on *.xhtml
old answer on SO. Tried removing <welcome-file-list>
from web.xml
. ALL trial FAILED!!!! Any suggestion about where things are going wrong would be really appreciated.
Here is web.xml
content:
<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>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Navigation rule in faces-config.xml
is as follows, because I don't have any link for admin.xhtml yet:
<navigation-rule>
<from-view-id>/pages/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>result</from-outcome>
<to-view-id>/pages/result.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
Using, JBoss AS 7.1, RichFaces 4.0, JSF 2.0 (via JBoss Tools)
Upvotes: 1
Views: 13436
Reputation: 529
The externalContext approach works fine for me.
<h:body>
#{facesContext.externalContext.response.sendRedirect('pages/admin.jsf')}
</h:body>
Upvotes: 0
Reputation: 103
Redirection from root (index.html) on JSF RichFaces
1.Put in xhtml file.
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=index.jsf">
</head>
</html>
2.Web.xml file
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
Upvotes: 0
Reputation: 8574
Since the URL is invoked by the browser, you need to resolve the url like this:
<meta http-equiv="Refresh" content="0; URL=#{request.contextPath}/pages/admin.jsf"/>
See also:
Upvotes: 2