I want to send a message (example : String msg = "Hello";) from Servlet to JSP (myPage.jsp).
The flow: Step 1 : On myPage.jsp, there are multiple textboxes and various other data fields that the user fills and hits submit. Step 2: The control goes to Servlet, Servlet validation happens and a message needs to be returned back to the same JSP as an alert BOX.
NOTE : No data on myPage.jsp that was entered by the user should be deleted. Only an alert should pop up and user should be able to click OK on the alert box and continue working on myPage.jsp.
There are multiple links that tell about how to pass message from servlet to JSP.
How can I alert message in Servlet code and sendredirect to JSP page?
JSP and Servlet serverside validation
display a message coming from servlet on jsp page in javascript alert box
But none of these solve the condition: "No data on myPage.jsp that was entered by the user should be deleted. Only an alert should pop up and user should be able to click OK on the alert box and continue working on myPage.jsp."