0

i m using jsf2 and i have problem with logout.

In fact to connect to my application the url is

http://localhost:8080/myapplication/

here is the configuration :

login.jsp

<form method="post" action="j_security_check">
            <table>
                <tr>
                    <td>NNI :</td>
                    <td><input type="text" name="j_username"/></td>
                </tr>
                <tr>
                    <td>Mot de passe :</td>
                    <td><input type="password" name="j_password"/></td>
                </tr>
                <tr>
                    <td colspan="2" align="right"><input type="submit" value="Identifier"></td>
                </tr>
            </table>
        </form>

web.xml

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login.jsp</form-login-page>
        <form-error-page>/login_failed.jsp</form-error-page>
    </form-login-config>
</login-config>

all work fine with authentification, i m redirect to index.jsp

index.jsp

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head></head>
    <body>
        <jsp:forward page="/pages/start.jsf" />     
    </body>
</html>

and start.xhtml is my main page.

then i have add a LoginBean with :

public String logout() throws IOException {

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

    return "logout";
}

and in faces-config.xml

<navigation-rule>
    <from-view-id>/*</from-view-id>
    <navigation-case>
        <from-outcome>logout</from-outcome>
        <to-view-id>/login.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

and when i click logout, i m redirect to :

http://localhost:8080/myapplication/login.jsp

but when i try to re-login, login page is show another time, so i try to login again, but i have error message :

Etat HTTP 404 - /castorsurveillance-web/j_security_check

does it possible, when i m logout to redirect to

http://localhost:8080/myapplication/

instead of

http://localhost:8080/myapplication/login.jsp 

?

or another solution if a best one exist! :)

thanks!!

  • Which framework are you using to manage your login process? It should be possible to modify the url for your login endpoint. Anyway, have you tried with `
    `? See also: http://stackoverflow.com/a/29789634/1199132
    – Aritz May 02 '15 at 10:31
  • hello, its a basic authentification, i dont use spring-security or other, i m in a simple jsp page who submit j_security_check and all configuration is in web.xml to grant or not access of user that are in role mpo-user, in tomcat i have a tomcat-users.xml with authorized users, and in weblogic user come from ldap and mpo-user role grant access or not. so i don t have to do something else. no? – Mançaux Pierre-Alexandre May 04 '15 at 08:57

0 Answers0