Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes Cannot resolve type in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Cannot resolve type in jsp" Watch "Cannot resolve type in jsp" New topic
Author

Cannot resolve type in jsp

c york
Greenhorn

Joined: Mar 16, 2006
Posts: 28
Need help. The code that I am getting this error, worked before and now the error String literal cannot be resolved is appearing for Connection, the catch statement, Statement and ResultSet. I do not understand the error.


[BPSouther: Added code tags]
[ July 03, 2007: Message edited by: Ben Souther ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

First and foremost, you shouldn't be doing Java in the JSP, let alone SQL statements. It flies in the face of all that is considered good practice.

The first part of your solution should be to factor out the Java from your pages into Java classes.

That said, we can't help you solve this issue without the exact error message that you are getting.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
c york
Greenhorn

Joined: Mar 16, 2006
Posts: 28
I am a JSP/Java beginner and trying to learn as I go.

The exact error message is - Multiple annotations found at this line(Connection conn.....) Conn cannot be resolved, Connection can not be resolved to a type.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

Originally posted by c york:
I am a JSP/Java beginner and trying to learn as I go.


All the more reason not to learn the wrong way to do things in the first place!

So, step 1 is to remove the Java from the JSP and get it working in a bean that is independent of the JSP page.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

It looks like the error is due to not having imported the java.sql.Connection class.

That said, Bear is right. JSPs should not be written as though they are ASPs with the logic, the persistence and the view all jumbled together in the same file. That's OK for the quick-hack Microsoft world, but the reason to use J2EE is that it provides a more scalable, more secure, and generally higher-performing platform in exchange for the added complexity that it demands.

If you're learning JUST to do JSPs as imitation ASPs, you're missing the forest while concentrating on the trees.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot resolve type in jsp
 
Similar Threads
First connection, I want to do it !!!
Need Code Review
excepttion in thread "main" java.sql.SQLException: Io exception: The Network Adapter
what is HttpSessionBindingListener
Connection with database Help