Vincent Ly wrote:
I'm aware that this is a popular error:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 19 in the jsp file: /sample.jsp
Connection.Connect cannot be resolved to a type
16: try
17: {
18:
19: Connection.Connect con = new Connection.Connect();
Tim Slattery wrote:
Maybe it's just me, but I don't understand this. The "new" command is
used with a class name, it invokes the proper constructor and creates
a new instance of the class. Using "new" with a method makes no sense
Since he's using it with a constructor that isn't a problem. You've been
thrown off by the OP's unconventional capitalizing a package name.
to me. Also, "Connection" is an interface, and has no constructor. To
No, 'Connection' is not an interface here.
get one you use the getConnection static method of the DriverManager
class.
Looks to me like it should be something like:
Connection con =
DriverManager.getConnection(<arguments here>);
This would not work since in the OP's code 'Connection' is a package.
To the OP: By convention, package names are spelled in all lower-case,
particularly when there is a risk of confusion with a well-known type. Also,
your code might have been clearer with an 'import' and simple class names.
Also, naming a type with a verb is rather confusing; verbs are conventionally
used as method names and nouns or adjectives are used as type names. Tim's
confusion is understandable, for all that it could have been avoided with
very, very careful reading of your post.
I see, that makes sense. I'll try reorganizing the code a bit then.
Thanks.