title: Java AJAX webapp security
body: <p>I'm experimenting with creating a simple AJAX Java webapp. </p>
  
  <p>I'd like to use the container managed security provided by the Servlet container, but having investigated it have a feeling that it isn't going to work how I'd like it to. Basically I'd like to be able to have a login prompt on the main page, without the user having to navigate away to a login form.</p>
  
  <p>As an example imagine a simple message board application and a user who wants to post a new message enters the text directly into a form on the screen, when it comes to pressing the submit button I would like be able to make an ajax call to determine if the user is already logged in, if not then I'd like to display a login div on the same page to allow the user to log in without navigating away to a separate login page.</p>
  
  <p>The form based login provided by the servlet container seems to be based on the assumption that the user will be redirected to a separate login page at the point where they try to access something that is "secured", which isn't what I want to happen.</p>
  
  <p>So I suppose what I'd like to know is if there is a standard way of allowing users to login within a single page ajax application using the container managed security, or some 3rd party library? I'm going to have a look at Spring security, but at first glance it seems to have the same problem that I'm having with the standard security. </p>
  
  <p>EDIT:Found this very useful, think it may be the basis of my solution <a href="http://www.jroller.com/sjivan/entry/ajax_based_login_using_aceci" rel="nofollow noreferrer">http://www.jroller.com/sjivan/entry/ajax_based_login_using_aceci</a></p>