Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Unable to fetch config parameter in jsp 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 "Unable to fetch config parameter in jsp" Watch "Unable to fetch config parameter in jsp" New topic

Unable to fetch config parameter in jsp

chetan dhewal
Ranch Hand

Joined: Nov 07, 2000
Posts: 61
Hi All,

I am trying to fetch the configuration parameter from withing jspInit() method which i have overridden in my jsp code, although i am able to retrieve the context parameter.

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="" xmlns:xsi="" xsi:schemaLocation="">


JSP code
<%! public void jspInit()
ServletConfig cfg = getServletConfig();

String id = cfg.getInitParameter("email");

ServletContext ctx = getServletContext();

String name = ctx.getInitParameter("name");

System.out.print(id +" "+name);
<%! int counter = 0; %>
<%! int countermethod()
counter += counter + 2;

return counter;

<%= countermethod() %>

I think there is some servlet naming problem , but I am not able to pin point the problem. Is it not possible to get it or this is not the correct way of fetching cofig parameters.

With Regads

Chetan Dhewal<br />SCMAD,SCJP 1.2
Ashish Gauswami

Joined: Aug 20, 2008
Posts: 22
you just need to write a <servlet-mapping>. without <servlet-mapping> you are accessing your jsp as jsp, not as servlet. just add this to your web.xml and you are all good.

[ September 09, 2008: Message edited by: Ashish Gauswami ]

SCWCD - Preparing, SCJP - 86%
I agree. Here's the link:
subject: Unable to fetch config parameter in jsp
It's not a secret anymore!