| LMachado1@gmail.com 2005-04-06, 12:17 pm |
| 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:254)
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(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(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.java:191)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(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.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(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.invokeNext(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.processConnection(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java: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(PageContextImpl.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:210)
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(ApplicationFilterChain.java:247)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(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.java:191)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(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.invokeNext(StandardPipeline.java:643)
at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(StandardPipeline.java:641)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at
org.apache.catalina.core. StandardPipeline$StandardPipelineValveCo
ntext.invokeNext(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.invokeNext(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.processConnection(Http11Protocol.java:392)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java: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
|