Basically I'm working with the following code in Eclipse:
The classpath appears to be fine, and I get no errors in the code. However once try to run that code in Eclipse's internal browser, I get error messages like this:
Eclipse is configured to spot errors immediately, and if I comment out the imports, then I see errors on the lines like #17. When I de-comment the imports, all the errors magically go away, which tells me that to some extent, Eclipse is reading the jar file and importing everything. What's the deal?
#1: Java code doesn't belong in a JSP. Put this logic into a servlet where you have full control over the imports.
#2: Try it specifying the full class name: javax.mail.Session. It is possible there is another class "Session" being imported from a different package
#3: Watch out for SQL Injection. Use a prepared statement rather than building up a sql string via concatenation.
Joined: Aug 15, 2011
I forgot I had made this thread. Anyway coming back to it a while after I submitted the initial query, I'm gonna state what had gone wrong. Basically in Eclipse, even if you've got your path/classpath variables all set correctly, a dynamic web project won't work unless you put non-standard jars like the one I was trying to use in <project name>\WebContent\WEB-INF\lib. Earlier I just had the jar somewhere else on my computer, but even setting the path/classpath variables properly, it wouldn't work; you just have to put those things into that specific folder for some reason.