This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hoping someone can provide some further direction. I have it pretty clear in my head how to do the general assignment (at least I think so) except for one part, how do we maintain the list of videos in memory. I could write them out to a file but that seems to go against what is being asked for and jdbc is yet to come. Therefore I have to assume that the arrayList is held in memory somehow but one I leave the servlet page or write the video to the arrayList I lose the reference to it. I'm assuming this is where the mystery file comes in but I'm not sure. Any help would be appreciated. Thanks.
Originally posted by Ronald Schindler: ... how do we maintain the list of videos in memory. I could write them out to a file but that seems to go against what is being asked for and jdbc is yet to come.
Writing to a file is not maintaining the ArrayList in memory, it is persisting it. The same applies to jdbc. You will be persisting the list in a database. You don't need to persist the ArrayList for Servlets-4a.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Joined: Jul 11, 2000
Marilyn, That's exactly what I was thinking. But if the list is to persist in memory then it seems that it needs to have a reference kept to it at all times so that gc doesn't pick it up. When I leave a servlet and go to an html page, I would lose the reference and therefore the list. I was thinking about turning the html pages into servlets similar to the last assignment but wasn't sure if one, this was acceptable and two, if this would actually work. My assumption at this point is that the mystery file is supposed to maintain session somehow but I'm still thinking this through. Any other commentary is welcome. Thanks.
Excellent tip Darryl. You'll have to wait for Servlets-4b to play with sessions, Ronald.
Joined: Jul 11, 2000
Thanks for the instance comment that helped. Here's where I'm at now. I am successfully calling the AddVideoServlet and adding the video. I get a true on add and have a count increase when I add. So far so good. The ListVideoServlet however knows nothing about what was added. If I check to see what was added by AddVideoServlet, I get back a big fat 0 for the number of videos, which was my concern. ListVideoServlet has no knowledge of where the videos were added. How should it know where to look for what has been added into memory? My thoughts are that these objects need to be aware of each other but I'm not sure how to make that happen when they don't talk to each other.
Joined: Oct 16, 2001
When I get these types of problems, I usually try to hard-code some data into my data field (a static block in the class will perform operations upon class loading). Then try to perform a read. If you can read the data, your problem is with improper writing. If you can't read the data, then it's improper reading.
I can't remember how I arrived at a solution to this one, but it seems the clues were in the assignment itself. Now, since these two servlets can't talk to each other, it seems to me that they will have to communicate through a third party............
Hi Folks, is it necessary to use a "mystery.java"-file for this assignement? I did it without that and now I'm afraid the solution is not very proper!?
Kommt Zeit, kommt Bart!
Joined: Jan 19, 2001
There's usually more than one way to get a solution working for any of the assignments. (Anyone who's gone through nitpicking can attest to that!) Whether or not your solution is "proper" for the Cattle Drive, well, there's only one way to find that out - have to send it in to be nitpicked. Submitted solutions certainly don't need to "match" the instructor's solution exactly, but I suspect for this one you would be expected to come up with a "mystery file". The instructor's solution for Servlets 4a has a particular structure that highlights inheritance really nicely.