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 8570263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:31:08+00:00 2026-06-11T18:31:08+00:00

When i call the servlet, it doesn’t go to the desired jsp page. below

  • 0

When i call the servlet, it doesn’t go to the desired jsp page. below is the both codes

There’s an error in the log saying this but that’s not really a reason not to forward to the destination

     java.sql.SQLException: Bad format for number 'bb' in column 4.

calling the servlet with this code, pretty sure of the url mapping

    <a href="/Store/DisplayOrders"> Display Orders</a>



        package admin;

        import data.ConnectionPool;
        import data.DBUtil;
        import java.io.IOException;
        import java.io.PrintWriter;
        import java.sql.Connection;
        import java.sql.PreparedStatement;
        import java.sql.ResultSet;
        import java.sql.SQLException;
        import java.util.ArrayList;
        import javax.servlet.RequestDispatcher;
        import javax.servlet.ServletException;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;

        /**
        *
        * @author One
        */
        public class DisplayOrdersServlet extends HttpServlet {

            @Override
            public void doPost(HttpServletRequest request, HttpServletResponse response)
                    throws ServletException, IOException {
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();

                ConnectionPool pool = ConnectionPool.getInstance();
                Connection connection = pool.getConnection();
                PreparedStatement ps = null;
                ResultSet rs = null;

                ArrayList al = null;
                ArrayList ordersList = null;
                ordersList = new ArrayList();

                String query = "select * from orders order by order_id";

                try {
                ps = connection.prepareStatement(query);
                rs = ps.executeQuery(query);


                while (rs.next()) {

                    al = new ArrayList();

                    al.add(rs.getString("order_id"));
                    al.add(rs.getString("product_quantity"));
                    al.add(rs.getString("product_name"));
                    al.add(rs.getDouble("user_name"));
                    al.add(rs.getDouble("user_address"));
                    out.println("al :: " + al);
                    ordersList.add(al);
                }

                request.setAttribute("ordersList", ordersList);

                String url = "/admin/orders.jsp";

                    RequestDispatcher dispatcher =
                    getServletContext().getRequestDispatcher(url);
                    dispatcher.forward(request, response);
            }

            catch (SQLException e) {
                    e.printStackTrace();
                } finally {
                    DBUtil.closeResultSet(rs);
                    DBUtil.closePreparedStatement(ps);
                    pool.freeConnection(connection);

        }
            }

            @Override
            protected void doGet(HttpServletRequest request, HttpServletResponse response)
                    throws ServletException, IOException {
            doPost(request, response);

            }
        }

the jsp page

            <%@page contentType="text/html" pageEncoding="UTF-8"%>
            <%@ page language="java" import="java.util.*;"%> 
            <!DOCTYPE html>
            <HTML> 
            <HEAD> 
            <TITLE>Orders CRUD</TITLE> 

            </HEAD> 

            <BODY> 
            <br> 
            <table> 

            </table> 
            <br> 
            <table > 
            <tr><td></td></tr> 

                <tr><td ><a href="/Store/admin/#.jsp">#</a></td></tr> 
            <tr><td></td></tr> 
            <tr> 
                <td>order_id</td><td>product_quantity</td><td>product_name</td> 
                    <td>user_name</td><td>user_address</td>
                    <td>Edit</td><td>Delete</td> 
            </tr> 
                    <% 
                    int count=0; 
                    List viewList = new ArrayList(); 
                    Iterator  viewItr; 

                    if(request.getAttribute("ordersList")!=null && request.getAttribute("ordersList")!="") 
                    { 
                            List orderList =  (ArrayList)request.getAttribute("ordersList"); 
                            Iterator itr = orderList.iterator(); 

                            while(itr.hasNext()) 
                            { 



                                    viewList = (ArrayList)itr.next(); 
                                    int product_id = Integer.parseInt(viewList.get(0).toString()); 
                                    viewItr = viewList.iterator(); 
                                    %> 
                                    <tr> 
                                    <%   
                                    while(viewItr.hasNext()) 
                                    { 

                                            %> 
                                            <td><%=viewItr.next()%></td> 

                                            <% 

                                    } 
                                    count++; 
                                    %> 
                                    <td><input type="button" name="edit" value="Edit" onclick="editRecord(<%=product_id%>);" ></td> 
                                            <td><input type="button" name="delete"  value="Delete" onclick="deleteRecord(<%=product_id%>);"></td> 
                                    </tr> 
                                    <% 
                            } 
                    } 
                    if(count==0) 
                    { 
                            %> 
                            <tr><td > </td></tr> 
                        <tr><td>No Record Avaliable</td></tr> 
                            <% 
                    } 
                    %> 
                <tr><td></td></tr> 
            </table>     
            </BODY> 
            </HTML> 
  • 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-11T18:31:09+00:00Added an answer on June 11, 2026 at 6:31 pm
    try {
      ...
      al.add(rs.getDouble("user_name")); <-- Exception thrown
      al.add(rs.getDouble("user_address"));
          ...
       String url = "/admin/orders.jsp";
      RequestDispatcher dispatcher =
       getServletContext().getRequestDispatcher(url);                        
      dispatcher.forward(request, response);
    } catch (SQLException e) {  <-- Exception catch
      e.printStackTrace();      
    

    When you get an exception, the code after the exception is skipped until the exception is catched. The redirection code is not executed at all. That said, getting a name or an address as a double is unusual.

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

Sidebar

Related Questions

How can I call a servlet from jsp ? But in this case, I
is there any way to call servlet or make a gwt-rpc call from gwt
I call a function like this: call_facebook(103138046395999, samåkning.se, http://www.facebook.com/samakning, page); call_facebook(16089699074, Jag ska köra
I am trying to call remote servlet from GWT, actually the GWT-RPC doesn't seems
javax.servlet.http.Cookie implements java.lang.Cloneable In Cookie method, there is a method call setSecure , what
I like to know why dont we call servlet constructor instead of init method
I want to call a Servlet from img src. I have defined a Servlet
I have an arraylist of objects in my servlet where I want to call
Is it possible to a jquery $.get() to call a servlet and use it
I am trying to call a servlet from jQuery's .ajax() function. At the moment

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.