If you use struts it would have been a lot easier and better than only JSP.
In struts :
Add this line in ur JSP page
<html:errors/>
In ur Action servlet ex: LoginAction.java add thsi code extract in the appropriate position ...
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.user.wrong"));
if (!errors.isEmpty())
{
saveErrors(request, errors);
}
But in JSP do something like this:-
If authentication fails then post to the same JSP and put this code in the reqd position...
<%
String postFlag=request.getParameter("postFlag");
if(postFlag.equals("FAILED"))
{
%>
LOGIN FAILED
<%
}
%>
So for JSp simply set the request parameter (postFlag) to SUCCESSFUL/FAILED from your servlet.