I'm using eclipse to develop a Java Web Dynamic Project. While calling the function:
JOptionPane.showMessageDialog(null, "Invalid Username or Password");
Both in running or debugging, the program will get stuck, and no alert window appears. And the program could never forward.
I'm using Tomcat 8.0 Server in eclipse Java EE to test the project. And the following is a piece of my code:
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
JOptionPane.showMessageDialog(null, "Invalid Username or Password");
}
And the function of doPost
is proved to be right. So what's the reason why the program get stuck and how to fix it?
JOptionPane is a Swing component, not something you would typically use on a web project. showMessageDialog is a blocking function, which explains why it is stuck. The doPost is server side and will need to return an error to the client. You should not perform UI operations here. The client will have to display the error when the POST is returned with the error in the response.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments