This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

ServletConfig doubt??

 
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I tried the some examples with regards to servlet config and context. When I say out.println(getServletConfig().getInitParameter("adminEmail")); and when I dont set any init params in the web.xml, the line prints null?? How and why this happens instead of giving an error??
 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you think it should give error?
use getServletConfig().getInitParameter("adminEmail").length() and see output
Then try to understand why getServletConfig().getInitParameter("adminEmail")
gives null and why getServletConfig().getInitParameter("adminEmail").length()
gives error.it is just basic java.
 
Joe Harry
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gowher,

I know that when you say .length(), it will give you a null pointer exception...My question is, how my servlet knows that when I say out.println(getServletConfig().getInitParameter("adminEmail")); or as a matter of fact out.println(getServletConfig().getInitParameter("Some stupid thing")); when there is no param-name tag in the DD that matches Some stupid thing???
[ January 04, 2007: Message edited by: Jothi Shankar Kumar Sankararaj ]
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "how my servlet knows"? The config parameter doesn't exist, so the call returns null. What do you think should happen instead?
 
Joe Harry
Ranch Hand
Posts: 10192
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

So if the parameter does not exist, it prints out null. Does this also applies to context param??I thing I got it.

Thanks ranchers.
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does this also applies to context param?


This kind of information is generally found in the javadocs.
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!