jsf - Logout from any page to the index page -


i have index.xhtml file, landing page of application.

i have logout button invokes following method:

public string logout() {     facescontext.getcurrentinstance().getexternalcontext().invalidatesession();     return "logout"; } 

which in turns forwards index.xhtml page faces-config.xml. however, when click on logout , reach index.xhtml page, page distorted, without css or design.

where getting wrong?

the canonical approach send redirect after invalidate of session, otherwise old session variables still present in response of current request.

provided you're using old fashioned jsf navigation cases, adding

<redirect /> 

to navigation case should do.

however, got externalcontext#invalidatesession() compile means you're using jsf 2.x. in case, can utilize implicit navigation facility without need navigation-case boilerplate:

return "/index.xhtml?faces-redirect=true"; 

if still doesn't fix problem, caused homegrown servlet filter overzealously blocks css (and js , image) resources when no logged-in user found. problem not related logout function, you'd have had same problem when being not logged-in @ all.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -