Hi,
I've written a small application consisting of an html page, a
jsp page and a
java class which I'l trying to deploy on
tomcat 6.0 I'm getting the following error:
An error occurred at line: 13 in the jsp file: /update.jsp
update cannot be resolved to a type
10: String test_val=request.getParameter("test_val");
11: String v1=request.getParameter("v1");
12: String v2=request.getParameter("v2");
13: update obj=new update();
14: obj.setValues(test_id , test_val , v1 , v2);
15: obj.getId();
16: obj.getTestVal(); Heres the stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) Here's the code for the jsp:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Updating the database</title>
</head>
<body>
<%@ page import="java.sql.*" %>
<%
String test_id=request.getParameter("test_id");
String test_val=request.getParameter("test_val");
String v1=request.getParameter("v1");
String v2=request.getParameter("v2");
update obj=new update();
obj.setValues(test_id , test_val , v1 , v2);
obj.getId();
obj.getTestVal();
obj.getVal1();
obj.getVal2();
int rows=obj.updateDB(test_id , test_val , v1 , v2);
%>
<p> Rows inserted in the database are: <%= rows %>. </p>
</body>
</html>
And here's the Java code:
import java.sql.*;
import java.lang.*;
public class update{
String emp_id , t_val , val1 , val2;
public void setValues(String test_id , String test_val , String v1 , String v2){
emp_id=test_id;
t_val=test_val;
val1=v1;
val2=v2;
}
public String getId(){
return emp_id;
}
public String getTestVal(){
return t_val;
}
public String getVal1(){
return val1;
}
public String getVal2(){
return val2;
}
public int updateDB(String emp_id , String test_val , String val1 , String val2)
throws SQLException , ClassNotFoundException
{
System.out.println("USAGE: update <id> <test_val> <val1> <val2>");
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc

racle:thin:@//localhost:1521/XE";
Connection conn = DriverManager.getConnection(url , "username" , "password");
conn.setAutoCommit(true);
Statement smt = conn.createStatement();
int rows=smt.executeUpdate("INSERT INTO
TEST(test_id , test_val , value1 , value2) VALUES('" + emp_id + "' , '" + test_val + "' , '" + val1 +
"' , '" + val2 + "')");
//System.out.println(rows + "rows inserted.");
return rows;
}
}
The HTML page and the JSP are placed under $install_dir/webapps/ROOT directory and the java file is under $install_dir/webapps/ROOT/WEB-INF/classes directory.
The TOMCAT_HOME, JAVA_HOME, classpath variables are all set in my environment. I just cant make out whats going wrong where.
Help is really appreciated!!!
Thanks!!
