0

This is configured in web.xml as-

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/ch9/ch9_5/expired.xhtml</location>
    </error-page>

And the structure in Eclipse is-

enter image description here

index.xhtml page-

    <h:body>                   
        Please, force view expiration!
        <h:form>
            <h:commandButton value="Logout!" action="#{logoutBean.logoutAction()}"/>
        </h:form>
    </h:body>

LogoutBean.java-

@ManagedBean
@javax.faces.bean.RequestScoped
public class LogoutBean {

    public String logoutAction() throws IOException {

        ExternalContext externalContext = 
                            FacesContext.getCurrentInstance().getExternalContext();
        externalContext.invalidateSession();

        return "byebye.xhtml?faces-redirect=true;";
    }
}

byebye.xhtml-

    <h:body>
        Bye, Bye session! You are logout! Press browser back button ...
    </h:body>

expired.xhtml-

    <h:body>
        Your session expired ...
        <h:link value="Go to Login Page ..." outcome="index.xhtml" />         
    </h:body>

This is shown in Google Chrome when the view is expired.

enter image description here

1) The first problem with this is that only the hardcoded text appears, and not the link,

Your session expired ...(link absent for index.xhtml)

2) How to reflect the error page url in the browser window?

3) Thirdly, in IE 11.0.9600, the error-page doesn't appear at all. What might be the reason for this? How to be consistent for both these browsers?

Farhan Shirgill Ansari
  • 13,172
  • 7
  • 49
  • 95
  • 1) answer: http://stackoverflow.com/q/3112946 2) related: http://stackoverflow.com/q/26588797 3) likely this: http://stackoverflow.com/q/9022932 – BalusC Apr 10 '16 at 13:59
  • @BalusC: Impressive. – Farhan Shirgill Ansari Apr 10 '16 at 14:13
  • As you basically asked three questions, it's hard to close this one as a duplicate. This Question would technically qualify as "Too broad". In the future try asking one question per Question :) – BalusC Apr 10 '16 at 14:16
  • @BalusC: It works perfectly when I have changed the url-pattern to (asterik.xhtml). The component gets parsed with FacesServlet being invoked. But I don't get it working with /faces/* with outcome attribute having value "/faces/ch9/ch9_5/index.xhtml". Its still unparsed. Would request you to please reflect on this. – Farhan Shirgill Ansari Apr 11 '16 at 06:41
  • You could try changing `` to include `/faces` prefix, but better just don't use JSF 1.0 style mappings at all and stick to `*.xhtml`. – BalusC Apr 11 '16 at 06:42
  • @BalusC: Now it works. The only reason I didn't ask 3 separate questions was to avoid duplicating the content I needed to put to illustrate. Furthermore, my search results couldn't yield those links suggested by you. I surmise the only way for you to so quickly suggest those links to me is by some reference which you must have maintained for your own internal use. But then it's just a guess. – Farhan Shirgill Ansari Apr 11 '16 at 06:56
  • I recall the majority of my answers by question's title and specific keywords I used in my own answers (yes I have a fairly strong memory). I just type question's title right away in browser's address bar and browser (Chrome) history autocompletes the rest. If it doesn't return the desired question, I peek at http://jsf.zeef.com. If I can't find it over there, I use Stack Overflow's own search engine here with `is:a` hint along with key words and/or codes from my own answer as search keywords. True, this is easier if you already know the answer, but that works for me :) – BalusC Apr 11 '16 at 07:03

0 Answers0