Forums Register Login

Servlet Loading-Attributes

+Pie Number of slices to send: Send
I did not understand why u cannot let one servlet in particular to run first(by giving highest load-on-start value in DD -in that case the servlet gets loaded and initialized even before the 1st request comes in) and put code inside that servlet to set servletcontext attributes(for entire web app)??HFS doesnt state why it is a wrong approach(ref page-164)
+Pie Number of slices to send: Send
Howdy -- good question. While you can certainly do it *technically*, I think it's more of a design approach that's the problem--that you would have a dependency on configuring that servlet to load first, and it's kind of an arbitrary way to initialize those things. If your application changes, you'd always have to remember to have one servlet configured to do that, and from an OO standpoint, it might not be the most cohesive to pick one servlet and designate it as The One To Do That Lookup Work. Whereas a listener might make a better design choice...

So, you're right, Sanday, that you could do this. It's a design issue that we were complaining about, but we should have been more clear in explaining WHY we said it like that.

cheers,
Kathy
+Pie Number of slices to send: Send
one more question--page 596 HFS-no dumb questions-it says u can save resources by not loading servlets that are rarely used in advance..but even if 1 client makes a request that results in loading of a particular servlet which is very rarely used it stays loaded till the web app goes down....isn't it a disadvantage???..i mean wouldn't it have been good had there been someway to unload the servlet without bringing the app down
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 427 times.
Similar Threads
SessionAttributes Doubt?
passing parameters from servlet to jsp
HFSJ question on session attribute
adding a new value to the request...
context getAttribute code doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 20:48:09.