Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JSP Coercion Error

Posted on 2006-06-05
3
Medium Priority
?
1,166 Views
Last Modified: 2012-05-05
Hello. I am developing an app for my employer, and I am encountering an error due to coercion somewhere in one of my pages. I am having trouble locating it. I hope someone can provide me with a bit of assistance.

exception
 
javax.servlet.ServletException: Attempt to coerce a boolean value "false" to type "java.lang.Long"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
      org.apache.jsp.jsp.process_jsp._jspService(process_jsp.java:2207)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
root cause
 
javax.servlet.jsp.el.ELException: Attempt to coerce a boolean value "false" to type "java.lang.Long"
      org.apache.commons.el.Logger.logError(Logger.java:481)
      org.apache.commons.el.Logger.logError(Logger.java:498)
      org.apache.commons.el.Logger.logError(Logger.java:566)
      org.apache.commons.el.Coercions.coerceToPrimitiveNumber(Coercions.java:422)
      org.apache.commons.el.Coercions.applyArithmeticOperator(Coercions.java:872)
      org.apache.commons.el.ArithmeticOperator.apply(ArithmeticOperator.java:83)
      org.apache.commons.el.BinaryOperatorExpression.evaluate(BinaryOperatorExpression.java:170)
      org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
      org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)
      org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:899)
      org.apache.jsp.jsp.process_jsp._jspx_meth_c_if_97(process_jsp.java:20735)
      org.apache.jsp.jsp.process_jsp._jspService(process_jsp.java:2100)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.



The code which causes it is:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%!String firstname;
 
      String lastname;
 
      %>
 
 
<%-- Check for valid session --%>
<c:if test="${validUser == null}">
      <jsp:forward page="../login.jsp">
            <jsp:param name="error" value="4" />
      </jsp:forward>
</c:if>
 
<%-- ****************Address Stuff  *********** --%>
 
<%-- Check if address/location exists --%>
 
<sql:query var="add_exists">
      SELECT
            *
      FROM
            address_table
      WHERE
            (address_1 = ?)
            
      <sql:param value="${param.add_1}" />
</sql:query>
 
<%-- if a record is returned, get the address id --%>
 
<c:if test="${add_exists.rowCount == 1}">
      <c:forEach items="${add_exists.rows}" var="add_row">
            <c:set var="add_id" value="${add_row.add_id}" />
      </c:forEach>
</c:if>
 
 
<%-- If 1 record is not returned from query, add the address--%>
<c:if test="${add_exists.rowCount != 1}">
      <sql:update var="insert_address">INSERT INTO address_table VALUES ( 0, ?, ?, ?, ?, ?, ?, ?, ? )
                  
            <sql:param value="${param.Company}" />
            <sql:param value="${param.Store_num}" />
            <sql:param value="${param.add_1}" />
            <sql:param value="${param.add_2}" />
            <sql:param value="${param.city}" />
            <sql:param value="${param.province}" />
            <sql:param value="${param.country}" />
            <sql:param value="${param.phone}" />
      </sql:update>
 
      <%--now get the address id.... --%>
 
      <sql:query var="add_exists">
                  SELECT
                        add_id
                  FROM
                        address_table
                  WHERE
                        (address_1 = ?)
            
            <sql:param value="${param.add_1}" />
      </sql:query>
 
      <c:forEach items="${add_exists.rows}" var="row">
            <c:set var="add_id" value="${row.add_id}" />
      </c:forEach>
</c:if>
 
 
<%-- ************  check if crew member1 exists, and get id# ****************--%>
<c:if test="${not empty param.Crew1_name}">
      <c:out value="testing to see if c1 exists " />
 
      <sql:query var="crew1_exists">
                        SELECT
                              *
                        FROM
                              crew_map
                        WHERE
                              (last_name = ?) AND (first_name = ?)
                      
            <sql:param
                  value='<%= com.acps.takedown.NameParserBean.parseLastname(request
                                    .getParameter("Crew1_name")) %>' />
            <sql:param
                  value='<%= com.acps.takedown.NameParserBean.parseFirstname(request
                        .getParameter("Crew1_name")) %>' />
      </sql:query>
 
      <c:if test="${crew1_exists.rowCount == 1}">
            <c:forEach items="${crew1_exists.rows}" var="crew1_row">
                  <c:set var="c1id" value="${crew1_row.person_id}" />
            </c:forEach>
      </c:if>
 
 
      <%-- if not, add him --%>
 
      <c:if test="${crew1_exists.rowCount != 1}">
            <c:out value="c1 does not exist, adding him" />
            <sql:update var="add_crew1">
                              INSERT INTO crew_map VALUES
                              (0, ?, ? )
            
                  <sql:param
                        value='<%= com.acps.takedown.NameParserBean.parseLastname(request
                                    .getParameter("Crew1_name")) %>' />
                  <sql:param
                        value='<%= com.acps.takedown.NameParserBean.parseFirstname(request
                        .getParameter("Crew1_name")) %>' />
            </sql:update>
 
            <%-- and then get the id --%>
            <sql:query var="crew1_get_id">
                        SELECT
                              *
                        FROM
                              crew_map
                        WHERE
                              (last_name = ?) AND (first_name = ?)
                      <sql:param
                        value='<%= com.acps.takedown.NameParserBean.parseLastname(request
                                    .getParameter("Crew1_name")) %>' />
                  <sql:param
                        value='<%= com.acps.takedown.NameParserBean.parseFirstname(request
                        .getParameter("Crew1_name")) %>' />
            </sql:query>
            <c:forEach items="${crew1_get_id.rows}" var="crew1_row">
                  <c:set var="c1id" value="${crew1_row.person_id}" />
            </c:forEach>
      </c:if>
</c:if>
 
 
<sql:update var="insert_job">INSERT INTO job_table VALUES ( 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?  )
                  
      <sql:param value="${param.Date}" />
      <sql:param value="${add_id}" />
      <sql:param value="${c1id}" />
      <sql:param value="${c2id}" />
      <sql:param value="${c3id}" />
      <sql:param value="${c4id}" />
      <sql:param value="${c5id}" />
      <sql:param value="${c6id}" />
      <sql:param value="${param.travel_time}" />
      <sql:param value="${param.start_time}" />
      <sql:param value="${param.end_time}" />
      <sql:param value="${param.delay_time}" />
      <sql:param value="${param.Comments}" />
</sql:update>
 
<sql:query var="job_id_check">
      SELECT max(job_id) AS max_job_id FROM job_table
</sql:query>
 
<c:forEach items="${job_id_check.rows}" var="job_row">
      <c:set var="job_id" value="${job_row.max_job_id}" />
</c:forEach>



Thank you for any and all help/suggestions/ideas. It is really appreciated!
0
Comment
Question by:Caydel
1 Comment
 
LVL 29

Accepted Solution

by:
bloodredsun earned 2000 total points
ID: 16835658
It might be because you have nested <c:if> statements

<c:if test="${not empty param.Crew1_name}">
...
     <c:if test="${crew1_exists.rowCount == 1}">
          <c:forEach items="${crew1_exists.rows}" var="crew1_row">
               <c:set var="c1id" value="${crew1_row.person_id}" />
          </c:forEach>
     </c:if>
...
</c:if>

Your jsp design would really benefit from having a backing action or servlet to do all this logic in rather than having in all in your presentation jsp. If this is not the root cause then I suggest that you fall back on the fairly basic tactic of commentating out large portions of your code until you find the relevent section.

To find out what exactly it is, you should look at the process_jsp.java file on line 2207. This can be found in <tomcat home>\work\Catalina\localhost\<your appname>\\org\apache\jsp

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will be showing you how to subnet the easiest way possible for IPv4 (Internet Protocol version 4). This article does not cover IPv6. Keep in mind that subnetting requires lots of practice and time.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question