How to terminate a request in JSP (not the "return;")

Posted by Genom on Stack Overflow See other posts from Stack Overflow or by Genom
Published on 2012-06-30T14:50:43Z Indexed on 2012/06/30 15:16 UTC
Read the original article Hit count: 134

Filed under:
|

I am programming a website with JSP. There are pages where user must be logged in to see it. If they are not logged in, they should see a login form. I have seen in a php code that you can make a .jsp page (single file), which checkes, whether the user is logged in or not. If not it will show the login form. If the user is logged in, nothing will be done. So in order to do that I use this structure in my JSPs:

Headers, menus, etc. etc... normal stuff which would be shown such as body, footer to a logged in user.

This structure is very easy to apply to all webpages. So I don't have to apply checking algorithm to each webpage! I can simply add this "" and the page is secure!

So my problem is that if the user is not logged in, then only the log in form should be shown and the footer. So code should bypass the body. Therefore structured my checklogin.jsp so:

If user is not logged in show the login form and footer and terminate request. The problem is that I don't know how to terminate the request... If I use "return;" then only the checklogin.jsp stops but server continues to process parent page! Therefore page has 2 footers! (1 from parent page and 1 from checklogin.jsp). How can I avoid this?

(There is exit(); in php for this by the way!)

Thanks for any suggestions!

© Stack Overflow or respective owner

Related posts about jsp

Related posts about httpwebrequest