Exploring Java Web Development, Part 2

Day two of reacquainting myself with JSP development, wherein we learn that IDEs are powerful tools but they are not very friendly to newcomers.

(Btw thanks to Red for helping out with this stuff.)

My first test was a hello world page using a simple one-property User class.  I got a static page working fine, but for some reason I couldn’t get Eclipse to import the class (<%@ page import=”User” %>).  It kept saying it couldn’t find it.

I figured it had something to do with GlassFish, so I installed Apache Tomcat 6 and set it up as a server in Eclipse.  This also didn’t work at first.  I kept getting “Project facet Sun Deployment Descriptors Files version 9 is not supported” errors.  Thinking GlassFish was still interfering somehow, I uninstalled the entire EE SDK.  Suddenly the import worked and the page loaded perfectly.  (I may not have those steps exactly right, so don’t quote me on it.  I think somewhere in there I also changed some project settings that had something to do with “facets.”)

(Around this time Eclipse stopped working, complaining that I didn’t have the JRE anymore.  I had both a 32-bit and 64-bit JRE and I think it got confused or something, so I uninstalled everything, then reinstalled a 32-bit JRE, the 32-bit SE SDK and the EE SDK (without starting GlassFish!).)

Feeling empowered, I next started a new project and imported some code I wrote many years ago for a Java class, which was a very, very simple bug-tracking app connected to a MySQL database.  I downloaded the latest MySQL JDBC connector, fixed a whole bunch of warnings and errors in the code that made me wonder how it ever worked before, and everything compiled cleanly (at least according to Eclipse).  But it didn’t come up in Tomcat with or without debug, complaining of a 404 Not Found.

It turned out all the .html and .jsp files need to go in the WebContent directory.  Okay, no problem – after moving the files, the index.html page came up.  But it bombed when I clicked into the .jsp pages because it couldn’t find the JDBC driver class.  After some more trial and error I discovered that the mysql-connector-java-5.1.10-bin.jar file needed to go in the WebContent/WEB-INF/lib directory.  (Not in the Project’s Libraries where I originally put it.)

And that’s where I left things, since I don’t actually have a copy of the database for this silly app, so I’ll need to recreate one before I can look at anything else.

2 Replies to “Exploring Java Web Development, Part 2”

  1. Pretty frustrating, huh? It’s a little easier once your familiar with the spec. Get a book on JEE 5. It’ll help a lot.

Comments are closed.