5 Replies Latest reply: Sep 29, 2011 3:42 AM by EJP RSS

    org.apache.jasper.JasperException: Unable to compile class for JSP:

    891428
      Hii,

      Any idea on this error?

      org.apache.jasper.JasperException: Unable to compile class for JSP:

      An error occurred at line: 16 in the jsp file: /1d0258c2440a8d19e716292b231e3190/delete_item_action.jsp
      Db.db cannot be resolved to a type
      13: for(int i=0; i<count;i++)
      14: {
      15: if(request.getParameter("checkbox_"+i).equals("delete"))
      16: Db.db.setUpdate("Update hardware set d_status=1 where hardware_Id="+request.getParameter("Id_"+i)+";");
      17:
      18:
        • 1. Re: org.apache.jasper.JasperException: Unable to compile class for JSP:
          EJP
          So Db.db cannot be resolved to a type.

          Did you forget to declare it? or omit an import?
          • 2. Re: org.apache.jasper.JasperException: Unable to compile class for JSP:
            891428
            Hi,

            I have done the following at the top of the page. Do I miss out something?

            <%@ page import="java.util.*"%>
            <%@ page import="java.lang.*"%>
            <%@ page language="java" import="DB.*" %>
            <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
            <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
            • 3. Re: org.apache.jasper.JasperException: Unable to compile class for JSP:
              EJP
              So where is the declaration of Db.db? Or Db itself for that matter?
              • 4. Re: org.apache.jasper.JasperException: Unable to compile class for JSP:
                891428
                The page is located at web/test/test.jsp and the java as below
                Is there anything still need to add to test.jsp?

                DB.java (web/classes/DB/db.class)
                ------------------------------------------------------------------------------
                package DB;
                import java.sql.*;

                public class db
                {
                String db_url="jdbc:mysql://localhost:3306/DB";
                String db_user="root";
                String db_password="123456";
                private ResultSet r=null;
                static private ResultSet res=null;
                int staff_Id=0;

                /** Creates a new instance of db */

                public int getRetrieveId()
                {      
                try{
                     Class.forName("com.mysql.jdbc.Driver").newInstance();
                     }
                     catch (Exception E)
                {
                     E.printStackTrace();
                     }
                     try{
                Connection C = DriverManager.getConnection(db_url,db_user,db_password);
                Statement S = C.createStatement();
                r = S.executeQuery("select max(staff_Id) from staff");
                while(r.next()){
                staff_Id=r.getInt(1);
                }
                S.close();
                C.close();

                }
                catch(Exception e)
                {
                e.printStackTrace();
                }
                return staff_Id;
                }

                public static boolean getSearch(String s)
                {   
                String search_db_url="jdbc:mysql://localhost:3306/DB";
                String search_db_user="root";
                String search_db_password="123456";
                String str=null;
                boolean result=false;

                try{
                     Class.forName("com.mysql.jdbc.Driver").newInstance();
                     }
                     catch (Exception E)
                {
                     E.printStackTrace();
                     }
                     try{
                Connection C = DriverManager.getConnection(search_db_url,search_db_user,search_db_password);
                Statement S = C.createStatement();
                res = S.executeQuery(s);
                while(res.next()){
                str=res.getString(1);
                }
                if(!str.equals(null))
                {
                result=true;
                }
                S.close();
                C.close();

                }
                catch(Exception e)
                {
                e.printStackTrace();
                }
                return result;
                }


                public void setUpdate(String str)

                try{
                     Class.forName("com.mysql.jdbc.Driver").newInstance();
                     }
                     catch (Exception E)
                {
                     E.printStackTrace();
                     }
                     try{
                Connection C = DriverManager.getConnection(db_url,db_user,db_password);
                Statement S = C.createStatement();
                int r = S.executeUpdate(str);
                S.close();
                C.close();

                }
                catch(Exception e)
                {
                e.printStackTrace();
                }
                }

                }
                • 5. Re: org.apache.jasper.JasperException: Unable to compile class for JSP:
                  EJP
                  Java is case sensitive, didn't you know that? DB amd Db are two different things to Java, and a class called db must be in a file called db.java; conversely a file called DB.java must contain a class called DB. You need to sort all this out, it is a complete mess at the moment.