-1

It's a really wierd problem

I'm trying to create an Object with type imLol and I'm getting the following error:

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

An error occurred at line: 13 in the jsp file: /yBillie.jsp
imLol cannot be resolved to a type
10: </head>
11: <body>
12:     <%
13:         imLol x = new imLol();
14:         List<Object[]> r = x.xgetNearCoupons();
15:         Users z = Users.getInstance();
16:         


An error occurred at line: 13 in the jsp file: /yBillie.jsp
imLol cannot be resolved to a type
10: </head>
11: <body>
12:     <%
13:         imLol x = new imLol();
14:         List<Object[]> r = x.xgetNearCoupons();
15:         Users z = Users.getInstance();
16:         

i.e. the class imLol not found

but in the same time I can use the object Users which in the same class. what's going on?

yBillie.jsp:

<%@page import="java.util.List"%>
<%@page import="implementations.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <%
        imLol x = new imLol();
        List<Object[]> r = x.xgetNearCoupons();
        Users z = Users.getInstance();

    %>
</body>
</html>

imLol.java:

package implementations;

import java.util.List;

import org.hibernate.SQLQuery;
import org.hibernate.Session;

public class imLol {
    public List<Object[]> xgetNearCoupons() {
        Session s = Controller.getSessionFactroy().openSession();
        s.beginTransaction();
        String mylat = "33.207933", mylng = "35.570246";
        int R = 6371;
        SQLQuery query = s.createSQLQuery("SELECT * FROM Businesses WHERE CAST(business_id AS DECIMAL(10) = 1");
        List<Object[]> l = query.list();
        s.getTransaction().commit();
        return l;
    }
}

Eclipse diagram:

enter image description here

eclipse doesn't make a red line below the imLol, but when I change it, to gjioarege, for example, it does.. what's wrong here?

Billie
  • 8,938
  • 12
  • 37
  • 67

3 Answers3

0

Can you check if the class imLol is in class path? Probably missing in the deployment. Check in WEB-INF/classes or in WEB-INF/lib as a jar.

0

As you can see, there is a red exclamation mark on your project. I bet it is a classpath problem, then compiler fails.

Michele Mariotti
  • 7,372
  • 5
  • 41
  • 73
0

There is red exclamation mark on the project that means it is the problem with build path.

You can view the problem tab by pressing ALT + SHIFT + Q followed by X.
In problem tab you will see the errors and warnings as well.

To solve the problem follow these steps

  1. Right click on the project
  2. Build path ----> Configure Build Path...
  3. Click Libraries tab

There might be problem with JRE or Web server library

  • If there is any problem you will see the red cross under that library. Just select that and remove.
  • To add it back again click on button Add Library...
  • If you removed JRE library then select JRE System Library, click next
    • Select Workspace default JRE
    • Click Finish
  • If you removed Server library then select Server Runtime, click next
    • Select the server (e.g. Apache Tomcat)
    • Click Finish
  • Click OK

Do not write scriptlets in JSP, because scriptlets shouldn't be used in JSPs for more than a decade. Learn the JSP EL, the JSTL, and use servlet for the Java code.
See How to avoid Java Code in JSP-Files?

Community
  • 1
  • 1
Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90