Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page language="java" contentType="text/html; charset=windows-1255"
- pageEncoding="windows-1255"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <%@ page import ="java.sql.*" %>
- <%!
- void connectDB(){
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection(connectionURL, "root", "root");
- statement = connection.createStatement();
- } catch (Exception e) {
- System.out.println("error in connecting");
- }
- }
- %>
- <html>
- <head>
- <title>JSP Page</title>
- </head>
- <body>
- <%
- connectDB();
- int no=0;
- rs = statement.executeQuery("SELECT * FROM users");
- while (rs.next()) {
- no++;
- }
- if(no==0)
- response.sendRedirect("errorsearch.html");
- rs.close();
- String queryString = "DELETE FROM users WHERE trim(username)='" +request.getParameter("username") + "'";
- try {
- int n = statement.executeUpdate(queryString);
- statement.close();
- connection.close();
- } catch (SQLException ex) {
- System.out.println("SQLException: " + ex.getMessage());
- System.out.println("SQLState: " + ex.getSQLState());
- }
- response.sendRedirect("usershow.jsp");
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment