David Newton wrote:Either use an OSiV filter (meh--can cause performance issues if you're not careful), or initialize what you're looking at in the backing servlet/action/controller/whatever.
David Newton wrote:I suppose you *could*, but that kind of code really doesn't belong in a JSP.
Bear Bibeault wrote:Pretty much all your Hibernate stuff should be handled on the back-end.
Are you using the "open session in view" filter?
(PS. don;t be confusing Hibernate sessions with servlet sessions -- not related).
Are you placing a User instance into the scope before the JSP is loaded?
(And, of course, at this stage of the game, scriptlets should not be used in JSP pages.)
Bear Bibeault wrote:You're micro-managing your error handling.
You should have a centralized error handler. Don't bother checking in the servlets. If something fails, an exception is thrown and will be handled in one place.
David Newton wrote:All Hibernate/DB stuff should be handled in the servlet/whatever, not in the JSP. Don't store the user ID in the session, otherwise you have to look up the user on every request: store the user object in session.
No, use the error handling capabilities of the deployment descriptor.Bai Shen wrote:And the way to do that would be to set up a Filter to catch any errors?
David Newton wrote:I already told you: initialize the collection in the servlet, not the JSP.
Bear Bibeault wrote:
No, use the error handling capabilities of the deployment descriptor.Bai Shen wrote:And the way to do that would be to set up a Filter to catch any errors?
David Newton wrote:This has nothing to do with web stuff though--this is a Hibernate issue ;)
Call Hibernate.initialize(theUser.getAgency()).
Or just don't make it lazy, if you always need it.
David Newton wrote:I'm saying it should go into the servlet that's used to display the JSP, or if it's not a huge object just initialize it on login and it'll follow the user around in the session.
David Newton wrote:The point of the servlet/JSP combination is to move Java code into the servlet, and to keep the JSP as simple as possible. HTML generation should be done in the JSP. Java code should be done in the servlet.
David Newton wrote:Yep :)
I brought this back from the farm where they grow the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|