0

After the delete below how can this page be redirected to the previours page and do a refresh to not show the data deleted?

I tried some options like:

<%
    String redirectURL = "Index.jsp";
    response.sendRedirect(redirectURL);
%>

but did not work. Should it just work with complete urls? am I doing this right also or this is not the best practice?

Thanks you!

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page language="java"%>
<%@page import="java.lang.*" import="org.postgresql.*"
    import="java.sql.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
</head>
<body>
    <%
        try {

            Class.forName("org.postgresql.Driver");
            String url = "jdbc:postgresql://localhost:5432/postgres";
            Connection connection = DriverManager.getConnection(url,
                    "postgres", "admin");

            String strquery = "DELETE FROM projects WHERE project = '"
                    + request.getParameter("project") + "'";

            Statement st = connection.createStatement();

            //System.out.println("Connecting to database...");
            ResultSet rs = st.executeQuery(strquery);

            System.out.println(strquery);

            pageContext.forward("Index.jsp");

            rs.close();
            st.close();
        } catch (Exception e) {
            System.out.println(e);
        }
    %>
</body>
</html>
letakeda
  • 155
  • 3
  • 12

0 Answers0