Reputation: 26978
I have several pages that have the same master template, which contains the header with a log out button. When I try to log out from all pages it works correctly except for one - the one which has request parameters in its URL.
After logout (session invalidation), I'm redirecting back to the login page as follows:
return "/login.xhtml?faces-redirect=true";
When I press logout on URLs like this,
http://localhost:8080/WPA_MOVIEDATABASE/app/index.xhtml
then the redirect works fine and I end up in:
http://localhost:8080/WPA_MOVIEDATABASE/login.xhtml
However, when I press logout on URLs with a request parameter like this,
http://localhost:8080/WPA_MOVIEDATABASE/app/movie.xhtml?id=135
then I'm redirected back to the same URL without the query string:
http://localhost:8080/WPA_MOVIEDATABASE/app/movie.xhtml
Am I doing the redirecting wrong or is this the normal behivour for these kind of URLs?
Upvotes: 2
Views: 1302
Reputation: 26978
In the HTTP Server Monitor I found out that after pressing the logout button, there was first a POST request
to
http://localhost:8080/WPA_MOVIEDATABASE/app/movie.xhtml
and then would follow a GET request
to
http://localhost:8080/WPA_MOVIEDATABASE/login.xhtml
.
At that moment I knew the problem was in the log out button..
I was using:
<h:form>
<h:commandLink value="Log out" action="#{userBB.logout}"/>
</h:form>
Changing the code to the following resolved the problem:
<h:button value="LOG OUT" outcome="#{userBB.logout()}" />
A million thanks to BalusC whose tips led me to discovering the true problem!
Upvotes: 0