config.getInitParameter always return null
The canonical way is to just use the inherited GenericServlet#getInitParameter()
in the argumentless init()
method (and remove any init(config)
method).
@Override
public void init() throws ServletException {
filename = getInitParameter("addressfile");
}
If that still doesn't work, then your web.xml
is not properly been deployed, or you have a typo in the parameter name, or you actually accessed a different instance variable than filename
to use/test it.
Ensure your servlet is calling super.init(config) on its init method, else it won't work.