This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What is the use of ServletContext in servlets? What can I use in servlets which helps all servelts in an application to use a particular object? Say, I have an object abc which is an instance of the class ABC. The class ABC is in the lib directory. I have created an instance of ABC in servlet1, ---initialized it. What do I do in servlet1 to enable servlet2, servlet3 and servlet4 all access the abc object? And while retrieving abc in servlet2, servlet3 and servlet4, what will the piece of code look like?
The servlet context will let you do what you want. It has application scope. Check out coreservlets.com for some good background info. -- Mike
Joined: Jan 19, 2004
Thanks Mike. But can you give me 3-4 lines of code snippets (in servlet1 and servlet2)for the problem I mentioned so that it would help me get going? I can then read up accordingly and code. I have developed a few servlets before so not entirely a new programmer but yeah, not very experienced either.