Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with ServletContext

 
Aleks V. Pascoal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why i can't use the getServletContext twice in the same Servlet? I used it in the init then in the doGet. The second time returns null.
Can anyone help me with that?
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aleksvp
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
Which init method did you use? If you used the one that takes a ServletConfig object as a parameter you have to call super.init(config). It is the init method that gets the ServletContext and makes it available.
If that's not the case then post some of our code that calls the methods and also your init method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic