Many servlet’s developers are confuse about the different between “ServletConfig” and “ServletContext”. Actually the “ServletContext” name is quite confusing, it should change to “AppConfig” or “AppContext” in the future release 🙂 ContextConfig 1) This is one per “web application”, access globally by all the servlets’ class 2) web.xml – within the web-app element and outside […]

Read more Different between ServleConfig and ServletContext

Here’s a serlvet code example to demonstrate how to pass a parameter to a servlet by using ServletConfig “init-param” in web.xml In the deployment descriptor (web.xml) Put your parameter value in “init-param” and make sure inside the “servlet” element <servlet> <servlet-name>ServletName</servlet-name> <servlet-class>com.mkyong.ServletDemo</servlet-class> <init-param> <param-name>email</param-name> <param-value>[email protected]</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>ServletName</servlet-name> <url-pattern>/Demo</url-pattern> </servlet-mapping> Servlet code public void […]

Read more How to pass parameters to a servlet – ServletConfig