Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:18:15+00:00 2026-06-18T02:18:15+00:00

I have a jsp web page. I need to delete the username from database

  • 0

I have a jsp web page. I need to delete the username from database when i press the delete button from the web page. I tried the codes below but I cant delete the name, instead it insert a new row and an empty value in the username database.

Here’s my codes

UnblockServlet.java :

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

String username = request.getParameter(“username”);

System.out.println("username="+username);


CustomerInfor unblockUser = new CustomerInfor();


unblockUser.setUsername(username);




CustomerInforDBAO unblockuserdb = new CustomerInforDBAO();


String status = unblockuserdb.blockUser(unblockUser);
System.out.println("Deleted user from blocked:" + status);

if (status== "success"){
    dispatch(request,response,"/success.jsp");  

}

else{
    dispatch(request,response,"/error.jsp");    

}

}

CustomerInforDBAO.java :

public String unblockUser(CustomerInfor unblockUser){
    Connection con = getConnection(true);
    PreparedStatement stmt = null;
    int status=1;
    String select = "DELETE * FROM paybuddy.blocked where username=?";
    try{
        stmt = con.prepareStatement(select);
        stmt.setInt(1,unblockUser.getId());
        stmt.setString(2,unblockUser.getUsername());

        status = stmt.executeUpdate();
    } catch (Exception e){
        e.printStackTrace();
        unblockUser = null;
    } finally {
        try{
            if (stmt != null) stmt.close();
            if (con != null) con.close();
        }catch (SQLException e) {}
    }
    if(status!=1)
        return "error";
    else
        return "success";

        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:18:17+00:00Added an answer on June 18, 2026 at 2:18 am
    public String unblockUser(CustomerInfor unblockUser){
    Connection con = getConnection(true);
    PreparedStatement stmt = null;
    int status=1;
    String select = "DELETE  FROM paybuddy.blocked where username=?"; // no *
    try{
        stmt = con.prepareStatement(select);
        //stmt.setInt(1,unblockUser.getId()); is this needed?
        stmt.setString(1,unblockUser.getUsername());
    
        status = stmt.executeUpdate();
    } catch (Exception e){
        e.printStackTrace();
        unblockUser = null;
    } finally {
        try{
            if (stmt != null) stmt.close();
            if (con != null) con.close();
        }catch (SQLException e) {}
    }
    if(status!=1)
        return "error";
    else
        return "success";
    
        }
    

    and check if ur calling the proper function above.

    String status = unblockuserdb.blockUser(unblockUser);
    

    should it be

    String status = unblockuserdb.unblockUser(unblockUser);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to access a page allCommonPageLink.jsp from another page named add_edit.jsp I have
Hi I have a page in my java/jsp based web application which shows list
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
I have opened a JSP web project in Eclipse but not sure how to
Under a Java EE enviroment, I have a web page built including several JSP
I have developed a web application using JSP which creates a page with several
In my application I have configured an error page in web.xml. I need to
I have a struts 2 (jsp) web application with MySQL database . Is it
Still learning JSP Web Applications here. I have been doing this for a while
I have a dynamic web project (JSP) on Eclipse that runs on a tomcat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.