Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Submit BOOLEAN type to Java Bean using FORM  -- getting type mismatch

Posted on 2004-11-01
7
Medium Priority
?
1,056 Views
Last Modified: 2010-08-05
gettig error from following code... pls help

***** BEANTEST.JSP*********

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head><title>Let's Test a Bean</title></head>
<body bgcolor=white text=black link=black vlink=black>

<%
      if (request.getParameter("reload") != null) {
%>
      <jsp:useBean id="formHandler" class="coreservlets.beans.UserBean" scope="session" />

      <jsp:setProperty name="formHandler"
                         property="username"
                         value='<%= request.getParameter("username") %>' />

      <jsp:setProperty name="formHandler"
                         property="password"
                         value='<%= request.getParameter("password") %>' />

      <jsp:setProperty name="formHandler"
                         property="changed"
                         value='<%= request.getParameter("changed") %>' />
      
      <jsp:forward page="./Controller.jsp" />
            
<% } else { %>
      <center><b>WELCOME! -- Let's Test a Bean</b>
      <br>
      <form action='<%= response.encodeURL("BeanTest.jsp?reload=true") %>'>
            Username: <input type="text" name="username"><br>
            Password: <input type="password" name="password"><br>
            property isChanged() = boolean true<br>
            <input type="hidden" name="changed" value=true><br>
            <input type="submit" name="reload" value="Reload" >
      </form>      
      </center>
<% } %>

</body>
</html>

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: argument type mismatch
      org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:665)
      org.apache.jsp.BeanTest_jsp._jspService(BeanTest_jsp.java:75)
      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

java.lang.IllegalArgumentException: argument type mismatch
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:324)
      org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:663)
      org.apache.jsp.BeanTest_jsp._jspService(BeanTest_jsp.java:75)
      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.28 logs.
A

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
 
<%@ page import="java.util.*" %>
<jsp:useBean id="formHandler" class="coreservlets.beans.UserBean" scope="session"/>

**** CONTROLLER.JSP *******
<html>
<head>
<title>Using jsp:setProperty</title>
</head>

<body>
      <center>
            <b>Page has been forwarded</b><br>
            username = <jsp:getProperty name="formHandler" property="username"/><br>
            password = <jsp:getProperty name="formHandler" property="password"/><br>
            changed = <jsp:getProperty name="formHandler" property="changed"/><br>
            <b>Horray it worked!</b>
      </center>
</body>
</html>

***** USERBEAN.JAVA ********

package coreservlets.beans;

import java.util.*;

/** use bean to represent DB user */

public class UserBean {
      
      private String username;
      private String password;
      private boolean changed;
      
      public String getUsername() {
            return(username);
      }
      
      public String getPassword() {
            return(password);
      }
      
      public boolean isChanged() {
            return(changed);
      }
      
      public void setUsername(String username) {
            this.username = username;
      }
      
      public void setPassword(String password) {
            this.password = password;
      }
      
      public void setChanged(boolean changed) {
            this.changed = changed;
      }
      
}
0
Comment
Question by:benk-master-flash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 

Author Comment

by:benk-master-flash
ID: 12464648
c'mon, read the code and help me out
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12465198
maybe try change:

public void setChanged(boolean changed) {
          this.changed = changed;
     }

to:

public void setChanged(string changed) {
          this.changed = (changed.equalsIgnoreCase("true"))?true:false;
     }

?
0
 

Author Comment

by:benk-master-flash
ID: 12465325
went through that, and the server responds
rg.apache.jasper.JasperException: Can't find a method to write property 'changed' of type 'boolean' in a bean of type 'coreservlets.beans.UserBean'
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Ryan Chong
ID: 12465406
opps, should it be:

public void setChanged(String strchanged) {
          this.changed = (strchanged.equalsIgnoreCase("true"))?true:false;
     }
0
 
LVL 28

Accepted Solution

by:
rrz earned 600 total points
ID: 12470093
Try changing this  
     <jsp:setProperty name="formHandler"
                     property="changed"
                     value='<%= request.getParameter("changed") %>' />
to this
     <jsp:setProperty
                              name="formHandler"
                              property="changed"
                              param="changed" />
I think that the conversions will done automatically then.       rrz
0
 
LVL 2

Expert Comment

by:siliconeagle
ID: 12481784
or
<jsp:setProperty name="formHandler" property="*"/>
0
 
LVL 28

Expert Comment

by:rrz
ID: 12505045
The points should have been split, siliconeagle's solution should work as well.    rrz
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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