This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 81

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: 42958
It's called "param", not "parm". Programming is all about paying attention to detail.
upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 81

Thanks for your reply
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Servlet initparameter not displaying
It's not a secret anymore!