Submitting form to Servlet which interacts with database results in blank page

You need to properly handle exceptions. You should not only print them but really throw them.

Replace

    } catch (Exception e) {
        e.printStackTrace(); // Or System.out.println(e);
    }

by

    } catch (Exception e) {
        throw new ServletException("Login failed", e);
    }

With this change, you will now get a normal error page with a complete stacktrace about the cause of the problem. You can of course also just dig in the server logs to find the stacktrace which you just printed instead of rethrowed.

There are several possible causes of your problem. Maybe a ClassNotFoundException or a SQLException. All which should be self-explaining and googlable.

See also:


Unrelated to the concrete problem, your JDBC code is prone to resource leaking and SQL injection attacks. Do a research on that as well and fix accordingly.

Leave a Comment