aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes cannot be resolved to a type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "cannot be resolved to a type" Watch "cannot be resolved to a type" New topic
Author

cannot be resolved to a type

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
What do you mean by this error ?? - "cannot be resolved to a type"

I am trying to run the SkipPageException example given in HFSJ


These are my files.


PageA.jsp




PageB.jsp


Simple.tld



SimpleTagTest2.java



And the exact error is :

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

An error occurred at line: 6 in the jsp file: /PageB.jsp
SimpleTagTest2 cannot be resolved to a type
3: This is page B that invokes the tag that throws SKipPageException.
4: Invoking that tag like NOW
5:
6: <myTags:simple2/>
7:
still in page B after the tag invocation..........................



Anybody , Any Idea?!


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

First of all, before going any further, I'd put the tag class in a package. You should not (must not) use the default package with JSP2.0. So put the class in a package, recompile and restart the container.


[My Blog]
All roads lead to JavaRanch
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Thanks Christophe ! That worked perfectly!

I didn't get one thing. Why is package so important.
I thought it was optional and just for my convenience....
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

From the JSP specification, JSP.11.2 JSP Page Implementation Class
As of JSP 2.0, it is illegal to refer to any classes from the unnamed (a.k.a. default) package. This may result in a translation error on some containers, specifically those that run in a JDK 1.4 or greater environment. It is unfortunate, but unavoidable, that this will break compatibility with some older JSP applications. However, as of JDK 1.4, importing classes from the unnamed package is not valid (see http://java.sun.com/j2se/1.4/compatibility.html#source for details). Therefore, for forwards compatibility, applications must not rely on the unnamed package. This restriction also applies for all other cases where classes are referenced, such as when specifying the class name for a tag in a TLD.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Thanks!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: cannot be resolved to a type