I fear that you're not clear about the lifecycle of a JSP. All your Java code within the <% ... %> gets executed at the server itself. If you're hoping that an alert message will be displayed to the client while the server is executing the Java scriplet then you're completely mistaken.
You need to capture the scenario of displaying an alert in a request attribute and pass it to the JSP, where you can check on the value and display the alert accordingly.
You need to capture the scenario of displaying an alert in a request attribute and pass it to the JSP.
Thank you very much .Seems valuable ,In my scenario how can i achive this .
// Setting some parameters in request scope here to send it to the other page
Please tell me
Joined: Feb 22, 2005
Before you forward the control to the JSP, in your servlet [or whatever handler class you've got], put in the following -
In your JSP you can then check on this attribute value and alert the user this way -
That should do it. But I hope that you've gone through the JSP lifecycle text and understand the mistake you were making.