Jasper compiler error
DevguyNov 24 2010 — edited Nov 26 2010pls look the program below..
<%@ page import = "java.sql.*" %>
<%
Connection con=null;
PreparedStatement ps=null;
public void jspInit()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
ps=con.prepareStatement("INSERT INTO EMPLOYEE VALUES(?,?,?)");
}//try
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
}//jspinit()
public void jspDestroy()
{
try
{
if(ps!=null)
ps.close();
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}//jspDestroy
%>
<%
String a = request.getParameter("empno");
String name = request.getParameter("name");
String c = request.getParameter("salary");
int empno = Integer.parseInt(a);
float salary = Float.parseFloat(c);
ps.setInt(1,empno);
ps.setString(2,name);
ps.setFloat(3,salary);
ps.executeUpdate();
%>
<%@ include file="emp.html"%>
When i runned it on tomcat server, jasper compiler gave the following error:+
An error occurred at line: 5 in the jsp file: /emp.jsp
Syntax error on token "void", @ expected
2: <%
3: Connection con=null;
4: PreparedStatement ps=null;
5: public void jspInit()
6: {
7: try
8: {
An error occurred at line: 5 in the jsp file: /emp.jsp
jspInit cannot be resolved to a type
2: <%
3: Connection con=null;
4: PreparedStatement ps=null;
5: public void jspInit()
6: {
7: try
8: {
An error occurred at line: 5 in the jsp file: /emp.jsp
Syntax error, insert "enum Identifier" to complete EnumHeaderName
2: <%
3: Connection con=null;
4: PreparedStatement ps=null;
5: public void jspInit()
6: {
7: try
8: {
An error occurred at line: 5 in the jsp file: /emp.jsp
Syntax error, insert "EnumBody" to complete BlockStatement
2: <%
3: Connection con=null;
4: PreparedStatement ps=null;
5: public void jspInit()
6: {
7: try
8: {
An error occurred at line: 22 in the jsp file: /emp.jsp
Syntax error on token "void", @ expected
19: e.printStackTrace();
20: }
21: }//jspinit()
22: public void jspDestroy()
23: {
24: try
25: {
An error occurred at line: 22 in the jsp file: /emp.jsp
Syntax error, insert "enum Identifier" to complete EnumHeaderName
19: e.printStackTrace();
20: }
21: }//jspinit()
22: public void jspDestroy()
23: {
24: try
25: {
An error occurred at line: 22 in the jsp file: /emp.jsp
Syntax error, insert "EnumBody" to complete BlockStatement
19: e.printStackTrace();
20: }
21: }//jspinit()
22: public void jspDestroy()
23: {
24: try
25: {
...I don't understand where the problem is.Any suggestions please...
Thanks in advance!!
Edited by: sandy on Nov 24, 2010 10:20 AM