1

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)

Community
  • 1
  • 1
shaz
  • 1,702
  • 10
  • 27
  • 66

3 Answers3

2

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:

Community
  • 1
  • 1
Ravi Kadaboina
  • 8,384
  • 3
  • 27
  • 42
  • your suggestion works when the problem is the path. But this is something different. RichFaces x.x need to have an index.jsf file to process, which can be just created and left empty. This solved the problem. – shaz Jul 09 '12 at 15:53
0

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>
Pravin
  • 103
  • 1
  • 14
0

The externalContext approach works fine for me.

<h:body>
  #{facesContext.externalContext.response.sendRedirect('pages/admin.jsf')}
</h:body>
Pavel Sedek
  • 489
  • 4
  • 13