• Post Reply Bookmark Topic Watch Topic
  • New Topic

config parameters for JSP

 
Velika Srbija
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Tomcat.
I know how to configure web.xml file in order to include init-parameters with designated servlet name. I also know how to read those parameters from my servlet class.
But how I could do that from my JSP page?
How should I configure web.xml file, and how should I read parameters from my JSP page?
 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Velika..
For getting web.xml initial parameters, you can use the ServletConfig object. In JSP you can use the PageContext implicit object to get this ServletConfig object by using the method getServletConfig(). On this ServletConfig object you can use the getInitParameter() and getInitParameters() methods to navigate and extract the initial parameters set through web.xml.
Ragarding setting the parameters to web.xml, I dont think there are API methods available to do so.
You can do one thing, when the application is started, you can initialise the parameters and set them with applicaiton scope.
Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!