How to show alert in a jsp from a servlet and then redirect to another jsp?
You may possibly do this:
else
{
out.println("<script type=\"text/javascript\">");
out.println("alert('User or password incorrect');");
out.println("location='index.jsp';");
out.println("</script>");
}
Edited: 20th March 2018, 08:19 IST
OR without using js
else {
out.println("<meta http-equiv='refresh' content='3;URL=index.jsp'>");//redirects after 3 seconds
out.println("<p style='color:red;'>User or password incorrect!</p>");
}
How to redirect from servlet to jsp after getting alert?
You can use something like this but i am not really recomend!
out.println("<script type=\"text/javascript\">");
out.println("alert('YOUR MESSAGE');");
out.println("window.location.href = \"YourPage.jsp\";");
out.println("</script>");
This is a tricky and easy way to do this! But you can do this with session
also if you want.
Alert inside a jsp page before redirect
you can try the redirection in javascript.
<script>
alert("Error");
window.location= "index.html";
</script>
Related Topics
Javac: File Not Found: First.Java Usage: Javac <Options> <Source Files>
Unit Testing Private Functions in Junit With Mockito
How to Show Alert in a Jsp from a Servlet and Then Redirect to Another Jsp
How to Get Amount of Tens in a Int
Batch Inserts Using JPA Entitymanager
How to Refresh a Stale Selenium Element If I Don't Have the Original Xpath
I Get a Status 200 When Connecting to the Websocket, But It Is an Error
The Highest Even Number in a Array
Java Check If a String Is Valid Json or Valid Xml or Neither
Adb Cannot Connect to Daemon At Tcp:5037
Find Maximum Score or the Maximum Average Score of Candidate Scores Given in Two Dim Array
How to Change Cookie Processor to Legacycookieprocessor in Tomcat 8
Java Spring @Scheduled Tasks Executing Twice
Type Safety: Unchecked Cast from Object to Arraylist<Myvariable>
Avoid Keycloak Default Login Page and Use Project Login Page