Setting up Glassfish and displaying a JSP page

The steps to set up Glassfish are here: https://glassfishplugins.dev.java.net/eclipse33/index.html

I pretty much followed the above steps EXACTLY and it worked like a charm.

So…since I really didnt use the JDBC code much in the last example…lets throw it away and redo (or reuse) the project that was created on that link above. Just make sure it has a name your willing to live with for a little bit.

Again, make sure to add your MySQL jar file into the build path as well as the lib directory in the application directory.

I moved the JDBC code into a helper class that did a few SQL queries and produced some HTML.

So there are two java classes.

MemberListHelper.java Connects to the database and gets the list of users as well as the user data for a single user.

WorkoutDatabase.java A constant file for now. I thought I would need it, but I really dont.

These two files are used by the following JSP files.

MemberList.jsp

The MemberList.jsp calls the helper to display a list of users.

If you click on a link, it goes to the second jsp page.


MemberData.jsp

This displays

Pretty simple.

Note that there is a TON of things wrong with this. First off, we are hand building html. Yuck. JSP does this so much better. And this helper class goes WAY against the whole MVC concept. We will be working on this. Eventually, the data (JDBC) will be abstracted out behind a “business delegate”. The data we get back will not be HTML but java beans. All Java will be removed from the JSP and we will use EL to display the data.

However, I like to build projects small steps at a time.

All my code for this is here. Again, Im hoping that you are familar with JSP and web applications. Assuming you know what WEB-INF or at least learning, you should know where to put this code.