I've been trying to learn web-apps recently, but I haven't used much Java before so I had a few design questions regarding JSP/beans.
Basically, my web-app uses CSS to define the layout, menu, etc. I use beans to build tables of information (such as messageboards, lists of users, etc.). Within the JSPs, I simply do things like checking the user's access status (i.e. whether an administrator or not) and displaying the appropriate content. I include the layout files in every JSP with the include file directive.
I wasn't quite sure of the best/most efficient way to do a few things. Is it OK to query the database within beans? Or should a servlet do this and save the results to a bean? Right now I have the bean doing it since a servlet on every page seemed like unnecessary overhead.
Next, regarding scope on beans - right now I have essentially everything set to session scope. I figured this would let me be more memory-efficient with objects. But a few problems arise with this model - for example, I need to issue clear commands to Vectors holding information every time a bean's "display" method is called. I'm not sure if this is good design on two counts: 1. Should I even be storing information from the DB in vectors, if I'm querying the DB each time a page is loaded? 2. I may be saving memory by using session scope, but is the clear method for vectors expensive? It just seems hack-ish to constantly clear vectors after displaying the output on each page.
Finally, I'm also writing a messageboard for use on the page. Right now, each message is represented as an object - I thought this made the most sense OOP-wise (since people can edit, delete individual messages), but I'm worried about memory usage again. Is it better to simply output query results as a single string to the page and save memory but repeat some code, or leave it the way it is with each message as an object?
Thanks for the help, and sorry for being so long-winded.