aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt on servlets 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 "Doubt on servlets" Watch "Doubt on servlets" New topic
Author

Doubt on servlets

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi,
Given the partial Deployment Descriptor:
<context-param>
<param-value>email</param-value>
<param-value>foo@bar.com</param-value>
</context-param>


<servlet>
<servlet-name>a</servlet-name>
<servlet-class>com.bar.Foo</servlet-class>
<init-param>
<param-name>email<param-name>
<param-value>baz@bar.com</param-value>
</init-param>
</servlet>

And assuming scfg is a servletconfig object and sctx is a servletcontext object, how does
scfg.getServletContext().getInitParameter("email") return foo@bar.com?

My doubt is how scfg is assosicated with servletcontext?

Please help me.
With regards,
Padma priya N.G.


Padma priya N.G.
Be the change you want to be - Mahatma Gandhi
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Is this a doubt or a question?

If it is a question, please take a look at the API and see what the association between the objects is. that should help you.
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Sorry I could not answer more fully in my earlier post.

HttpServlet has 2 methods (inherited from GenericServlet) called getServletConfig and getServletContext. getServletConfig returns a ServletConfig object that has a getServletContext method. Both getServletContext methods return the same object. This is just the way GenericServlet and HttpServlet were designed. Try executing the 2 calls to obtain the ServletContext from your HttpServlet class and you will see that they return the same ServletContext object
Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 434
Hi Michael,
Thanks for the nice explanation.
With regards,
Padma priya N.G.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on servlets