Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

JasperException/ServletException when using useBean...help!!
I'm using an HTML form to get some input from the user and then send
the input to a database.  Everything was working fine, but then I
decided to use a drop down box for one of the input methods in the form
instead of a checkbox and now I keep getting a JasperException and a
SErvletException.

here is the FORM code:

<form method="POST" action="addtohave.jsp">
<p align="center">
ISBN<sup>*</sup>:   <INPUT TYPE=TEXT name="isbn"
size="13" maxlength="13">      
Price:   <input type=TEXT  name="price" size="7"
maxlength="7">      
I am willing to:  
<select name="transtype">
<option value="sell">Sell it</option>
<option value="trade">Trade it</option>
<option value="both">Sell or Trade</option>
</select>
Condition:   
<select name="condition">
<option value="poor">Poor</option>
<option value="fair">Fair</option>
<option value="average">Average</option>
<option value="good">Good</option>
<option value="excellent">Excellent</option>
</select>

 ****************************************
************************************
*************
the following is my class:

package bkwrmspackage;

public class addToHave {

String isbn;
String price;
String transtype;
String condition;

public void setIsbn(String value){
isbn = value;
}

public void setPrice(String value){
price = value;
}

public void setTranstype(String value){
transtype = value;
}

public void setCondition(String value){
condition = value;
}

public String getIsbn(){
return isbn;
}

public String getPrice(){
return price;
}

public String getTranstype(){
return transtype;
}

public String getCondition(){
return condition;
}
}

 ****************************************
************************************
****
and now the jsp page that is doing all the work after the form is
submitted:

<%@ page
import = "java.io.*, java.lang.*, java.sql.*, java.util.*,
bkwrmspackage.*"
%>

<jsp:useBean id="input" class="bkwrmspackage.addToHave"
scope="session"/>
<jsp:setProperty name="input" property="*"/>

<HTML>
<HEAD><TITLE>BookWorms - Add To Have List ...</TITLE></HEAD>
<BODY>

<%
Connection dbconn;
PreparedStatement sql;
try
{
Class.forName("org.gjt.mm.mysql.Driver");
try
{
String name;
boolean isNotValidISBN = false;
boolean isNotValidPrice = false;


dbconn=DriverManager.getConnection("jdbc:mysql://localhost/group10","group10
","3i7d2");
Statement statement = dbconn.createStatement();

//check if any of the input is not appropriote
isNotValidISBN = (input.getIsbn() == null);
isNotValidPrice = (input.getPrice() == null);

//check if ISBN is valid
try
{
int len = input.getIsbn().length();
if (len != 13)
isNotValidISBN = true;
long i =
Long.parseLong(input.getIsbn());
}
catch( NumberFormatException nfe )
{
isNotValidISBN = true;
}

//check if Price is valid
try
{
StringTokenizer st = new
StringTokenizer(input.getPrice());
String dollars = st.nextToken(".");
int i = Integer.parseInt(dollars);
String cents = st.nextToken();
int j = Integer.parseInt(cents);
}
catch ( NumberFormatException nfe ) {
isNotValidPrice = true;
}

if(isNotValidISBN == false && isNotValidPrice
== false)
{
String query = "INSERT INTO havelist (isbn,
price, transtype, condition) VALUES ('" + input.getIsbn() + "','" +
input.ge\
tPrice() + "','" + input.getTranstype() + "','" + input.getCondition()
+ "')";
statement.executeUpdate(query);
}
//send user to index.jsp
else
{
//display errors & send user back to
original page.
if(isNotValidISBN ==
true){out.println("Invalid ISBN<br>");}
if(isNotValidPrice =
true){out.println("Invalid Price<br>");}
}
}
catch (SQLException s)
{
out.println("SQL Error<br>" + s.getMessage());
}
}
catch (ClassNotFoundException err)
{
out.println("Class loading error");
}
%>

 ****************************************
************************************
******************
the following is the error output:

type Exception report

message

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

exception

org.apache.jasper.JasperException:
bkwrmspackage.addToHave.getTranstype()Ljava/lang/String;
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
54)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
at java.lang.Thread.run(Thread.java:536)

root cause

javax.servlet.ServletException:
bkwrmspackage.addToHave.getTranstype()Ljava/lang/String;
at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:536)
at org.apache.jsp.addtohave_jsp._jspService(addtohave_jsp.java:146)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:641)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invok
eNext(StandardPipeline.java:643)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
at java.lang.Thread.run(Thread.java:536)


 ****************************************
************************************
****************
I have no idea what the problem is...as you can see the error output is
not very helpful. any help here would be greatly appreciated. I
remembered to recompile my class again after modifying it and I've
triple checked that I changed all the variable names where needed.

Thanks in advance,
--Lucas


Report this thread to moderator Post Follow-up to this message
Old Post
LMachado1@gmail.com
04-06-05 05:17 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Beans archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:04 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.