Error in JSP Page : Unable to compile class for JSP
I have a login page which I enter my username and password and click submit. It goes tovalidate.jsp as shown below. When this is invoked i get a strange error as shown beow the code
<html>
<body>
<%@ page errorPage="errorpage.jsp" language="java" import="java.sql.*" %>
<%
Connection conn =null;
ResultSet rs =null;
try{
String username=request.getParameter("username");
String password=request.getParameter("password");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:bob","scott","tiger");
PreparedStatement statement= conn.prepareStatement("select * from users where username=? and password =?");
statement.setString(1, username);
statement.setString(2, password);
rs = statement.executeQuery();
if(rs!=null && rs.next()){
session.putValue("user",username);
if(username.equals("admin")){
response.sendRedirect("admin.htm");
}
else{
out.println("Logged IN");
response.sendRedirect("SearchCriteria.jsp");
}
}
else{
response.sendRedirect("invalidUser.htm");
}
}
catch(Exception e){
out.println("Error "+e.printStackTrace());
}
finally{
rs.close();
conn.close();
}
%>
</body>
</html>
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 32 in the jsp file: /validate.jsp
The operator + is undefined for the argument type(s) String, void
29:
30: }
31: catch(Exception e){
32: out.println("Error "+e.printStackTrace());
33: }
34: finally{
35: rs.close();
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)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.

