Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes getServletConfig()  in pageContext() not working Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "getServletConfig()  in pageContext() not working" Watch "getServletConfig()  in pageContext() not working" New topic
Author

getServletConfig() in pageContext() not working

sasikumar palakkizhi
Greenhorn

Joined: Sep 11, 2005
Posts: 29
Hi all,

I was experimenting with the init-param of a jsp file. My web.xml is



and the jsp page "BasicCounter.jsp" is



I got a result


My email is null
email is null

client email is alima1965@yahoo.com


I expected that since pageContext object is available in the page I can access the init-param values using that object. The same is the case with application object too. What is the reason for this behaviour?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you want to add init-params to a JSP via web.xml, you need to create a servlet mapping for your JSP and use the url defined in that mapping when making the request.

Context init params, on the other hand are bound to the Context object (which is available to all components of the app) will be available, regardless of how your JSP was invoked.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
sasikumar palakkizhi
Greenhorn

Joined: Sep 11, 2005
Posts: 29
Hi Mr.Ben Souther,

It is working fine. Thanks for the reply.. When I mapped in web.xml, all the implicit objects are available in the page..

Thanks once again for the immediate answer

sasikumar
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: getServletConfig() in pageContext() not working
 
Similar Threads
Getting Junk Values While overridding jspInit()
getServletConfig
A question about servlet initParameter
i get ' null ' for jsp init params
Problem - Configuring init parameters for jsp