• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what's going on over here? HFSJ page 157

 
Jamed
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo everyone,

this is on page 157 of the HFS book.
*******************************************************************
out.println(getServletContext().getInitParameter("adminEmail"));

or ServletContext context = getServletContext(0;
out.println(context.getInitParameters("adminEmail"));
********************************************************************

the book says that every servlet inherits a getServletContext() method. that's understood so we can use it anywhere in a servlet..

then it says The getServletContext() method returns a servletContext object and one of it's methods is getInitParameters? what does that mean? can anyone paraphrase this to me in more details ?

thanks in advance guys,

Jamed

[ May 16, 2005: Message edited by: Moh'd Al Jamed ]
[ May 16, 2005: Message edited by: Moh'd Al Jamed ]
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I guess you havent read the complete chapter or not read about context param completely

In the DD we define a context param as

<context-param>
<param-name>adminEmail</param-name>
<param-value>abc@werty.com</param-value>
</context-param>

This value specified in the DD can be obtained using the code you specified

Is this what you were looking for ?
When the app is deployed , the containeer creates an instance of Servlet Context and passes to each servlet when a request is sent

Hope this clarifies everything

Regards
Shiva
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic