Cameron Harr's CS462 Page
Home  About  CS 462  Contact 
Lab 6 -- Entity Beans 100% Pure Vim Web Site
Home > Lab 6

 
Links:
  • Here's a jsp survey page that stores results in a DB.

Log:

    I must say that I don't like Beans. Well, Jelly Belly ones are fine, but these EJB's are too much of a pain if you ask me. But anyway...

    Like most of the labs, I largely used my previous java code to implement the current lab. I even got it to work with JSP which is nifty. What I basically did is where I previously used JDBC calls to write to the database before, I now have an EJB called SurveyBean that I create inside my main DispatchTagEJB.jsp file to take care of all the DB stuff. Probably the hardest part was getting the deletion to work correctly. Again, I previously used JDBC, but I needed to use EJB's. The problem is that where previously, I could use a serialize type for my primary key in the DB. However, since EJB's aren't nice enough for that, I made one by calling the system time in milliseconds and setting that as the column ID. Then, to delete it, I have another function in my DispatchTagEJB.jsp that gets called when the delete button is clicked and it reads all the beans with the findAll() call. I then use an Iterator class to go through each of the beans and then see if it is defined in the GET/POST parameters. If so, then I know that it was selected for deletion and I call the nifty thebean.remove() and that takes care of it for me.



For more great website ideas, visit Jaden.
Copyleft © 2002 Cameron No rights reserved.
Last Updated 03/01/02