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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:36:50+00:00 2026-06-15T16:36:50+00:00

Im currently new in java ee. I need help on how to pass my

  • 0

Im currently new in java ee. I need help on how to pass my data from jsp to my servlet to fil up my query. Whenever i run, the error is being catch and i print out the exception. It says java.null.exception.. I couldn’t find out where my error is..pls help me… thanks..

Here is my code:

UpdateProductServlet.java

    try {
        String description = request.getParameter("description");
        float price = Float.parseFloat(request.getParameter("price"));
        String size = request.getParameter("size");
        int aisle_id = Integer.parseInt(request.getParameter("aisle"));
        int id = Integer.parseInt(request.getParameter("id"));

        ProductsDao productsDao = new ProductsDao();
        productsDao.updateProduct(description, price, size, aisle_id, id);

    } catch (Exception e) {
        out.println(e);
    }

and my ProductDao.java

public void updateProduct(String description, float price, String size, int aisle_id, int id) 
        throws ClassNotFoundException, SQLException {
    Connection conn = null;
    PreparedStatement stmt = null;
    String sql = "UPDATE products "
            + "SET description = ?, price = ?, size = ?, aisle_id = ? "
            + "WHERE id = ? ";

    try {
        conn = ConnectionFactory.getConnection();
        stmt = conn.prepareStatement(sql);
        stmt.setString(1, description);
        stmt.setFloat(2, price);
        stmt.setString(3, size);
        stmt.setInt(4, aisle_id);
        stmt.setInt(5, id);
        stmt.executeUpdate();

    } finally {
        if (conn != null) {
            conn.close();
        }

        if (stmt != null){
            stmt.close();
        }
    }
}

and this is my ProductById.jsp

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    <script>
        function functionEdit()
        {
            document.getElementById("edit").type="hidden";
            document.getElementById("update").type="button";
            document.getElementById("delete").type="hidden";
            document.getElementById("cancel").type="button";

            document.getElementById("description").disabled="";
            document.getElementById("size").disabled="";
            document.getElementById("price").disabled="";
            document.getElementById("select").disabled="";
        }

        function functionUpdateRecord(){
            if(confirm('Update existing record?')){
                document.location.href="/MachineProblemWebApp/UpdateProductServlet";
                alert('Update success!');
                document.location.href="/MachineProblemWebApp/GetAllProductsServlet";

            }else{ 
                alert('No changes have been made!');
            }

        }

    </script>
</head>
<body>
    <table border="0">
        <tr>
            <td>id: </td>
            <td><input type="text" name="id" id="id" value="${product.id}" disabled="disabled"></td>
        </tr>
        <tr>
            <td>Description: </td>
            <td><input type="text" name="description" id="description" value="${product.description}" disabled="disabled"></td>
        </tr>
        <tr>
            <td>Aisle </td>
            <td><select name="aisle" disabled="disabled" id="select">
                    <c:forEach var="aisle" items="${aisles}" >
                        <option value="${aisle.id}" ${(aisle.id==product.aisle.id)?"selected" : ""}>${aisle.description}</option>
                    </c:forEach>
                </select></td>
        </tr>
        <tr>
            <td>Size: </td>
            <td><input type="text" name="size" id="size" value="${product.size}" disabled="disabled"></td>
        </tr>
        <tr>
            <td>Price: </td>
            <td><input type="text" name="price" id="price" value="${product.price}" disabled="disabled"></td>
        </tr>
        <tr>
            <td><input type="button" name="edit" id="edit" onClick="functionEdit()" value="Edit" >
                <input type="hidden" name="update" id="update" onClick="functionUpdateRecord()"value="Update">
                <input type="button" name="delete" id="delete" value="Delete">
                <input type="hidden" name="cancel" id="cancel" value="Cancel"></td>
        </tr>
    </table>

</body>

is this the stack trace? posted in Apache Tomcat Log?

Dec 10, 2012 7:38:13 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [UpdateProductServlet] in context with path     [/MachineProblemWebApp] threw exception
java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1008)
at java.lang.Float.parseFloat(Float.java:452)
at grocerific.ui.UpdateProductServlet.processRequest(UpdateProductServlet.java:45)
at grocerific.ui.UpdateProductServlet.doGet(UpdateProductServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Dec 10, 2012 9:36:40 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Dec 10, 2012 9:36:40 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
Dec 10, 2012 9:36:46 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 10, 2012 9:36:46 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Dec 10, 2012 9:36:46 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@8a47d9')
  • 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-15T16:36:51+00:00Added an answer on June 15, 2026 at 4:36 pm

    It seems you try to pass the data whit:
    document.location.href="/MachineProblemWebApp/UpdateProductServlet";

    and it is not possible, because this line just redirect to “UpdateProductServlet” without sending the data.

    you need to use the form tag to submit data.

    in the link below you can see how to set the form tag:
    http://www.w3schools.com/html/html_forms.asp

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

Sidebar

Related Questions

I'm new to java and packages and need some help navigating them. Currently I
I am quite new to Java and am currently coding an Android application. In
I am new to Java web-services and am working on one currently, using Apache
we are currently working on a new web application using Java and MySql. We
I'm new to Eclipse and am using it currently to play with Java EE.
Im currently using a java application to run commands on a unix box by
I'm currently translating an API from C# to Java which has a network component.
I'm pretty new to the SQL and need some help with a certain task.
I am currently writing a program in Java that will accept strings from PHP
I need help with understanding following example with @ModelAttribute from Spring documentation: (method populatePetTypes()

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.