aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes init() and ServletContext attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "init() and ServletContext attribute" Watch "init() and ServletContext attribute" New topic
Author

init() and ServletContext attribute

priya rishi
Ranch Hand

Joined: Oct 26, 2008
Posts: 119
i am trying to set an attribute for the ServletContext in init(ServletConfig) and get the attribute in the doGet() of the servlet.
but i get null.i dont know what i am doing wrong.any help.



SCJP 5 , SCWCD 5
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
From the servlet specification (see Servlet FAQ for links), see the bold part:

init(ServletConfig)
public void init(ServletConfig config)
throws ServletException
Called by the servlet container to indicate to a servlet that the servlet is being
placed into service. See Servlet.init(ServletConfig) .
This implementation stores the ServletConfig object it receives from the
servlet container for later use.
When overriding this form of the method, call
super.init(config)
.
priya rishi
Ranch Hand

Joined: Oct 26, 2008
Posts: 119
my program worked!!!

finally it prints, Hello Java!!!
thanks for the servlet spec quote.it helped.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: init() and ServletContext attribute