Once the user successful login to the system, the system will redirect the user to the homepage. Now my problem is, if the user clicks on the view account page without login
Not sure, but try doing this through ExternalContext facilities:
ExternalContext
Something like this:
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); externalContext.redirect(externalContext.encodeResourceURL(externalContext.getRequestContextPath()+getUrl()));