I've been trying to search for a way to redirect to an HTML file if a SQLException occurs. I'm going to give you an example.
I have my connection class something like this:
public class DBConection{
    Connection con = null;
    public DBConnection() throws RuntimeException{      
        try {
            Class.forName("org.gjt.mm.mysql.Driver");
            String user = "root";
            String pass = "12345";
            String db = "java";
            con = DriverManager.getConnection("jdbc:mysql://localhost/" + db, user, pass);
        }catch (ClassNotFoundException ex) {
            throw new RuntimeException();
        }catch (SQLException ex) {
            throw new RuntimeException();
        }
    }
}
and I'm calling it from a Servlet class,
public class ElectionsServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private static final String RETURN_PAGE = "index.jsp";
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        DBConnection con = new DBConnection();
        response.sendRedirect(RETURN_PAGE);
    }
}   
If an error ocurres during the DBConnection I want to redirect it to my RETURN_PAGE. Can anybody help me?
 
     
     
     
     
    