The moose likes JDBC and Relational Databases and the fly likes Servlet initparameter not displaying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Servlet initparameter not displaying " Watch "Servlet initparameter not displaying " New topic

Servlet initparameter not displaying

upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 82

Hi Ranch,
I was trying to print the servlet initParameter ,the web.xml is as follows

- <web-app xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="2.4">
- <servlet>
<servlet-name>Ch3 Beer</servlet-name>
- <init-parm>
- <servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>

my servlet class is

package com.example.web;
import javax.servlet.*;
import javax.servlet.http.*;
public class BeerSelect extends HttpServlet
public void doPost (HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
PrintWriter out=response.getWriter();
out.println("Beer Selection Advice<br>");
String c=request.getParameter("color");
out.println("<br>Got Beer Color"+" "+c);
ServletConfig cfg=getServletConfig();
String c1=cfg.getInitParameter("adminEmail");

but I am getting a null value kindly help

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
It's called "param", not "parm". Programming is all about paying attention to detail.
upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 82

Thanks for your reply
It is sorta covered in the JavaRanch Style Guide.
subject: Servlet initparameter not displaying
It's not a secret anymore!