samples/xml/servletapi/src/main/java/org/springframework/security/samples/servletapi/mvc/ServletApiController.java
@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String login(HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute LoginForm loginForm, BindingResult result)
			throws ServletException {
		try {
			request.login(loginForm.getUsername(), loginForm.getPassword());
		}
		catch (ServletException authenticationFailed) {
			result.rejectValue(null, "authentication.failed",
					authenticationFailed.getMessage());
			return "login";
		}
		return "redirect:/";
	}
@RequestMapping(value = "/login", method = RequestMethod.POST)
	public String login(HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute LoginForm loginForm, BindingResult result)
			throws ServletException {
		try {
			request.login(loginForm.getUsername(), loginForm.getPassword());
		}
		catch (ServletException authenticationFailed) {
			result.rejectValue(null, "authentication.failed",
					authenticationFailed.getMessage());
			return "login";
		}
		return "redirect:/";
	}
Demonstrates that you can authenticate with Spring Security using
{@link HttpServletRequest#login(String, String)}.

<p>
If we fail to authenticate, a {@link ServletException} is thrown that wraps the
original {@link AuthenticationException} from Spring Security. This means we can
catch the {@link ServletException} to display the error message. Alternatively, we
could allow the {@link ServletException} to propegate and Spring Security's
{@link ExceptionTranslationFilter} would catch it and process it appropriately.
</p>
<p>
In this method we choose to use Spring MVC's {@link ModelAttribute} to make things
easier for our form. However, this is not necessary. We could have just as easily
obtained the request parameters from the {@link HttpServletRequest} object.
Remember all of these examples would work in a standard {@link Servlet} or anything
with access to the {@link HttpServletRequest} and {@link HttpServletResponse}.
</p>

@param request
@param response
@param loginForm
@param result
@return
@throws ServletException