I had to access some init params in my sevlet. So, I put them in my web.xml





In my servlet code, I accessed it as

String uploadDir = getServletContext( ).getInitParameter(“upload-dir”);

My uploadDir turned out to be null. Then, i realised my fallacy.

getServletContext( ).getInitParameter gets you the init parameters configured in <context-param> of web.xml. If you want to access the parameters configured in <servlet> use this.getInitParameter(“upload-dir”).