Reputation: 15799
We're using JSF in a very simple way. All we're doing is implementing tags that contain a little Java code.
I have implemented a "security" tag that sends a 302 redirect back to the login page whenever the user isn't logged in:
// make them log in
ctx.getExternalContext().redirect("login.xhtml");
ctx.responseComplete();
The trouble is that the redirect() method doesn't stop the rest of the page being rendered. Tags that are further down the page are getting executed. This is a problem because non-logged-in users could see things they shouldn't if they had their browser ignore redirects.
How do I get responseComplete() to do what I thought it was supposed to do?
Upvotes: 0
Views: 1416
Reputation: 256
Try it!
ctx.getExternalContext().dispatch("login.xhtml");
ctx.responseComplete();
Upvotes: 0
Reputation: 3753
Its always better to implement the login related logic in a servlet filter, like below:
There are a lot of ways (may be better than this) to implement this, but this is the most basic one.
Upvotes: 1
Reputation: 527
Maybe you could use a flag to verify if the user is logged in.
Then, you can use the render=#{managedBean.logged}
property in the tags you don't want to render.
This is just a workaround... can't really help too much with that amount of information you gave.
Upvotes: 0