how to get error message on the same jsp

Hi guys,I have a login.jsp page and I want an error message to be printed "login failed" in the same jsp page when the user enters the wrong credentials.Any ideas on how to do that is highly appreciated.Thanx in advance.sri
[251 byte] By [sriarumillia] at [2007-10-3 1:20:00]
# 1
u can write the code for checking the username and password in the the login page itself and display the the output if the input is wrong which will printed in the same page.
dgpa at 2007-7-14 18:17:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

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.

RohitKumara at 2007-7-14 18:17:11 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...