This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JSP 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "cannot be resolved to a type" Watch "cannot be resolved to a type" New topic

cannot be resolved to a type

preet girn

Joined: Aug 28, 2012
Posts: 5
Hello to all,

when i was practise a small application i got the error msg "DogBean cannot be resolved to a type"

I have a html form that sends 2 parameter to a controller servlet(named,
In this servlet i set both of these parameters as attributes of next request, along with this i set an object of DogBean(a bean class containing 2 properties) as request attribute.
And call a JSP(using RequestDispatcher) named result.jsp (It will just display these attribute values).

<%= request.getAttribute("name") %> 1st attribute( contains the value of 1st parameter of HTML form)

<%= request.getAttribute("type") %> 2nd attribute( contains the value of 2nd parameter of HTML form)

<%= request.getAttribute("dog") %> 3rd attribute ( contains the object of DogBean)

gives the expected result

when i try to type cast it to DogBean the error occurs.

<%= ((DogBean)request.getAttribute("dog")).getDogname() %>

Compilation of JSP File '/result.jsp' failed:
result.jsp:9:7: DogBean cannot be resolved to a type
<%= ((DogBean)request.getAttribute("dog")).getDogName() %>

jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi Preet,

you need to import the dogbean in the jsp like you import the class in servlets.
Please mark the issue for close if you find the answer proper.

I agree. Here's the link:
subject: cannot be resolved to a type
It's not a secret anymore!