Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


chandrasekar
Init param
1 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners


What is the correct syntax of init param?


Advertisement
View Answers

March 20, 2008 at 10:03 PM


Hello,

Init parameters are added between the <init-param></init-param> tags under the <servlet></servlet> tags in the web.xml file.

For Example:

<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>roseindia.ReadInitParametersServlet</servlet-class>
<display-name>Read Initialization Parameters of the Servlet</display-name>
<init-param>
<param-name>emailHost</param-name>
<param-value>151.68.167.201</param-value>
</init-param>
<init-param>
<param-name>webMaster</param-name>
<param-value>Savitha Rajeev</param-value>
</init-param>
</servlet>

And then use the following code in servlet to read the parameter values.

public void init(ServletConfig config) throws ServletException {
String emailHost = config.getInitParameter("emailHost");
String webMaster = config.getInitParameter("webMaster");
}

or

public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String host = getServletConfig().getInitParameter("emailHost");
String master = getServletConfig().getInitParameter("webMaster");
}

Yes you must restart the application in the production environment.

If you server supports the reload of application then not required to restart the application server.

For example you can use tomcat manager to restart the application.


Thanks



Related Tutorials/Questions & Answers:
Init param - Java Beginners
Init param  What is the correct syntax of init param?  ...-name> <init-param> <param-name>emailHost</param-name> <param-value>151.68.167.201</param-value> </init
Init Parameter
Init Parameter  How set Init Parameter in servlet
Advertisements
init method
init method  why init method used in servlet?   The init() method is called only once by the servlet container throughout the life of a servlet. By this init() method the servlet get to know that it has been placed
difference between init() & init(ServletConfig config)?
difference between init() & init(ServletConfig config)?  I want to know the difference between init() and init(ServletConfig config) methods in GenericServlet
Access web.xml init parameters
Access web.xml init parameters  How to access web.xml init parameters from java code
Servlet Init method
Servlet Init method  can we capture the form data into the init method of the servlet
init method of ActionServlet and RequestProcessor
init method of ActionServlet and RequestProcessor  hi every when the ActionServlet init() method is executed? please give answer for the above query
init Method in Spring
init Method in Spring       Calling Bean using init() method in Spring, this section describes  the way to initialize a bean through its lifecycle events using the init
Getting Init Parameter Names
;web-app>  <servlet>  <init-param>  <param...;zulfiqar_mca@yahoo.co.in</param-value>  </init-param>  <init-param>...;Okhla</param-value>  </init-param>  <init-param>
JSP Include Param
JSP Include Param          JSP Include Param is used to pass parameter... illustrate an example from 'JSP Include Param'. To understand the example we
Struts2.2.1 param Tag Example
Struts2.2.1 param Tag Example This tag can be used to parameterize other... the param tag, the value can be defined in either a value attribute or as text.../html; charset=UTF-8"> <title>Example of Param
Standard Action "jsp:param"
; <jsp:include> Syntax: <jsp:param name="parameterName"...;jsp:forward page="jspparam2.jsp"> <jsp:param name="myParam" value="ANKIT KAUSHAL"/> <jsp:param
Param Tag (Data Tag) Example
Param Tag (Data Tag) Example       In this section, we are going to describe the param tag. The param tag is a generic tag.... The parameters can be added with or without a name as a key.  The param
Passing Parameters using <jsp: param>
page="ssParameters.jsp"> <jsp: param name="myParam" value="Amar Patel"/> <jsp: param name="Age" value
JSF param Tag
JSF param Tag      ... message where these param values can be used. Code Description : In the code below {0}and {1}are replaced by the param values specified within outputFormat tag
Why servletcontainer can,t call the Init() method ?
Why servletcontainer can,t call the Init() method ?  Why servletcontainer can,t call the Init() method
Facelet param Tag
Facelet param Tag      ...:composition template="/pages/param/paramtemplate.xhtml">...:param name="user" value="#{MessageBean.userid}"/>   
init Method in Spring
init Method in Spring       Calling Bean using init() method in Spring, this section... the init() method .Here we have defined the property and values of  the bean
init Method in Spring
init Method in Spring       Calling Bean using init() method in Spring, this section describes  the way to initialize a bean through its lifecycle events using the init
help to load information in init of application - Struts
help to load information in init of application  Thanks for ur... question related to struts2 framework I want to keep some data in init... that is in init of the application , please remember, i am using struts2
Use of <x:param> tag of JSTL
param tag to add these files as parameter to transform tag.  ... of the transformation parameter. param_xmlJstlTag.jsp <...-declaration="yes" indent="yes" /> <xsl:param name
Counter in Init() Method
: #000000; } Counter in Init() Method     ... and by reading the init parameter to know from where the counting will begin. In this program we are going to make use of the init method of the Servlet interface
What values initialized inside init() in servlet - Java Interview Questions
What values initialized inside init() in servlet  What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet
how to maKE Jcombox editable after saveing value init.
how to maKE Jcombox editable after saveing value init.  i have one JCombobox with 2 values"y", "N".when i selecting some value from dropdown... after saveing value init
@WebInitParam Annotation Servlet Example
; Here you can give the name and value of init param using the initParams attribute... = response.getWriter(); out.println("<h2>Init Param Servlet Example</h2>...://roseindia.net</param-value> </init-param> </servlet>
JSTL <c:import> with <c:param>
= "JSTLImportingDate.jsp"> <c:param name = "date" value = "<h1>So Have you
Request Parameters In EL
;/title> </head> <body> <h3>Request param name is : ${param.username}</h3><br> <h3>Request param ID no. is : ${param.id}</h3><br> <h3>Request param email is : ${param.email}<
Methods of Servlets
; A Generic servlet contains the following five methods: init() public void init(ServletConfig config) throws ServletException The init() method is called only once by the servlet container throughout the life of a servlet. By this init
Passing Parameters to Another JSP Page
introduce a new request parameter when calling a jsp page. This param tag can..." > <jsp:param name="name2" value="James" /> <jsp:param name="name3" value="Bill" />
Using tag <c:redirect> of Core JSTL tags
param is used to get parameter from request. Tag <c:forEach> is member
 

 

 

DMCA.com