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

  • SEARCH
  • Home
  • 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 7993571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:53:29+00:00 2026-06-04T13:53:29+00:00

I have a servlet that calls MySQL database. The deletePage method looks like this:

  • 0

I have a servlet that calls MySQL database.

The deletePage method looks like this:

public void  deletePage(PageData delete) {
    String firstQuery ="Delete FROM pages Where ID= '"+delete.getId()+"';";

    try {
        statement = connection.createStatement();
        statement.executeUpdate(firstQuery);
        System.out.println("Expense is deleting");

    } catch (SQLException e) {
        System.out.println("Expense isn't deleting - SQLException");
        e.printStackTrace();
    }
}

The delete.jsp is as follows:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add pages</title>
    </head>
    <body>
        <form action="adminController">
            <p>
                <input type="hidden" name="operation" value="deletepage" />
                <input type="hidden" name="parentid" value="<%= request.getParameter("id") %>" />
                Enter ID of page you want to delete:<input name="id"><br>

                <input type="submit" />
            </p>
        </form>
    </body>
</html>

The mainadmin.jsp:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Insert title here</title>
    </head>
    <body>
        <%= request.getAttribute("menu") %>
    </body>
</html>

if you run this code you’ll see that my delete buttons stands after each page name.
what i want to do is by pressing the delete button near the page to delete this page, there should be something like “are you sure you want to delete?”, submit button”delete”. but what i have managed to do looks like this(as in my code): whenever delete button is pressed, you have to enter id of page you want to delete, so no matter what delete button i press, it requests for id. but i just want to delete it right away.
can anyone help?

  • 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-04T13:53:31+00:00Added an answer on June 4, 2026 at 1:53 pm

    in adminController.java you have

    else if (operation.equals("delete")) {
        RequestDispatcher dispatcher = request.getRequestDispatcher("/delete.jsp");
        dispatcher.forward(request, response);
    
    } else if (operation.equals("deletepage")) {
        PageData pageData = new PageData();
        pageData.setId(request.getParameter("id"));
        dao.deletePage(pageData);
        response.sendRedirect("adminController");
    }
    

    change it to

    else if (operation.equals("delete")) {
        PageData pageData = new PageData();
        pageData.setId(request.getParameter("id"));
        dao.deletePage(pageData);
        response.sendRedirect("adminController");
    }
    

    you do not need the second operation ‘deletepage’, so you do not need delete.jsp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Under JBoss 4.0.1SP1, I have a servlet that makes multiple, concurrent calls to web
I have this java servlet that grabs information from a form, I need to
I'm writing a java servlet that calls a function in a jar. I have
I have a simple GWT project in Eclipse, it has a servlet that calls
I have code called from a servlet that calls out to an external service.
I have ajax calls that have the url http://localhost:80/Push/GetContacts?id=23 and the following servlet mapping:
I have a servlet that processes some content from the web and generates a
I have a servlet that users post a XML file to. I read that
I have a servlet that was running fine until a few days ago. But
I have a servlet that I cannot change ( com.sun.jersey.spi.container.servlet.ServletContainer of Jersey RS) .

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.