This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Web application in Eclipse : object cannot be resolved to a type in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Web application in Eclipse : object cannot be resolved to a type in JSP" Watch "Web application in Eclipse : object cannot be resolved to a type in JSP" New topic
Author

Web application in Eclipse : object cannot be resolved to a type in JSP

nimesh subramanian
Greenhorn

Joined: Oct 02, 2010
Posts: 5
I'm getting the following error.....
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 17 in the jsp file: /output.jsp
ServicePolicy cannot be resolved to a type
14: //ServicePolicy
15: String s = (String) session.getAttribute("heehe");
16: out.println("Hello "+s);
17: ServicePolicy obj = (ServicePolicy) session.getAttribute("policy");
18: //out.println("hello1" + obj.Availability);
19: //ServicePolicy p = new ServicePolicy();
20: Object p = (Object) session.getAttribute("policy");


Here servicepolicy is a java class that is there is src folder....
i have one more servlet which calls this output.jsp file.....in that a ServicePolicy object is putinto the session...
when i build it ...there are no errors...but when i run it ...this error comes...
what do i do??
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

If you were not using scriptlets, you wouldn't have such trouble !
Anyway, you need to import your class via the page directive. If your class is not in a package, put it in one.


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67

Indeed. Scriptlets and Java in JSPs have been discredited for over 8 years now. Time to update your JSP knowledge.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
nimesh subramanian
Greenhorn

Joined: Oct 02, 2010
Posts: 5
initially i thought that might be the problem and added a page directive to it...still the problem persists..

i even did ctrl+left click on the class in "eclipse" and it led me to the java page were i had defined the class...

in the JSP page..i created an object of my class...and then i realized that i couldn't access any of the variables that have been declared in it...

@Bear could you please explain what you ment by scriptlets and java in JSP has been discredited.......
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

i even did ctrl+left click on the class in eclipse and it led me to the java page were i had defined the class...

The fact that Eclipse knows where to find the class doesn't necessarily mean that Tomcat will know where to find it. Please show your page directive.

Also, your class file should be under the WEB-INF/classes directory of your application. Is it ?
nimesh subramanian
Greenhorn

Joined: Oct 02, 2010
Posts: 5
here is my import statement




i'm running my code from eclipse... and i cant find any .class file...in the project explorer window under my project....
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

The package explorer is used to show packages, classes and resources, not .class files. You can see them in the Navigator view.

Are you using a plugin to launch Tomcat ?
nimesh subramanian
Greenhorn

Joined: Oct 02, 2010
Posts: 5
the classes are in build/classes/...folder

when i click them and open them...it says.. "source not found. There is no source file attached to the class file filename.class"

yes. Added the tomcat that i installed into the serverruntime envirnoment and running it from eclipse....
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

This is not a JSP problem that you have here, but an Eclipse problem. Make sure your web application is configured to use your class files. I'm moving your thread to the Eclipse forum.
Fintan Conway
Ranch Hand

Joined: Apr 03, 2002
Posts: 141
Christophe Verré wrote:This is not a JSP problem that you have here, but an Eclipse problem. Make sure your web application is configured to use your class files. I'm moving your thread to the Eclipse forum.


Hi,

How do I do the above?

Many thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web application in Eclipse : object cannot be resolved to a type in JSP