Declare Servlet Init Parameters For JSP Page In web.xml File JSP Initialization FAQ

How To Declare Initialization Parameters For JSP Page In web.xml file

Servlet initialization parameters are declared  inside web.xml page and are used to pass the value to the servlet as a part of configuration.Now the question comes that since we do not make an entry for JSP inside web.xml page,how to pass the init parameters to the JSP page.We should remember that a JSP page is a servlet at the end of the day.A JSP is ultimately converted into a servlet then only it processes requests.Like the entry for init parameters in web.xml in case of servlet we make an entry for the JSP page as well,but with a slight difference.The web.xml file looks like this :


Here we can find that the same way as we declare  init paramters for servlet within the servlet tags,the same way we make an entry for the JSP page so that the init parameters can be declared for that particular JSP page.The only difference is that instead of he <servlet-class> tag we use <jsp-file> tag.The url pattern for the JSP page is same as the JSP file name as we use the JSP file name as URL pattern in the request.Inside the <jsp-file> tag we use the JSP file name with .jsp extension because we need to access the JSP page and not the servlet class.

This is the way we declare servlet init parameters for the JSP page inside the web.xml file.We call it as servlet init parameters for JSP page because these init parameters are sent to the servlet which is the result of translation of the JSP page.And these are used as the configuration parameters for the translated servlet.Now the init parameters can be accessed in he JSP page code.

Number of View :7541

Tags: , , , , , , ,

  1. #1 written by Antje August 8th, 2019 at 22:00

    Incredible! This bog loooks exactly like my
    old one! It’s on a totally different topic but it has pretty muc the same page layout annd design. Excellent choice
    of colors!

    RE Q

Content Protected Using Blog Protector By: PcDrome.