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

What is the correct syntax of init param?

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 Pages:
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
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>
Init Parameter
Init Parameter  How set Init Parameter in servlet
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
Servlet Init method
Servlet Init method  can we capture the form data into the init method of the servlet
Access web.xml init parameters
Access web.xml init parameters  How to access web.xml init parameters from java code
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
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
@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>
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
JSTL <c:import> with <c:param>
; <body> <c:import url = "JSTLImportingDate.jsp"> <c:param
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
Servlet - Servlet Interview Questions
;amardeep</param-value> </init-param> <init-param> <param-name>lastname</param-name> <param-value>Patel</param-value> </init-param> <init-param> <param-name>position</param-name> <
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" />
Getting Context Parameter Names
of the ServletContext to the context init parameters. The servlet and jsp which...;param-name>username</param-name> <param-value>roseindia</param-value> </context-param> <context-param> <
Understanding Struts Controller
-value>/WEB-INF/struts-config.xml</param-value>   </init-param>    <init-param>   <param...-value>2</param-value>    </init-param>
Applet Tag Parameters,Applet Tag in HTML
the applet's operation. APPLET parameters stored in the PARAM tag actually have little... to applets are: First, add the PARAM tag (with values) to the HTML source file....  Lets see how to Pass Parameters to the Applet <PARAM NAME
&lt;APPLET&gt; Tag Parameters: The &lt;PARAM&gt; Tag
the applet's operation. APPLET parameters stored in the PARAM tag actually have little... to applets are: First, add the PARAM tag (with values) to the HTML source file....  Lets see how to Pass Parameters to the Applet <PARAM NAME
Response Filter Servlet Example
to the response. Use the init-param child element of the filter element to declare the initialization parameter and its value. Inside the filter, access the init...-value>Hello Response Filter Example!</param-value>   </init
Using tag <c:redirect> of Core JSTL tags
param is used to get parameter from request. Tag <c:forEach> is member
Creating configuration files
; <init-param> <param-name>createTempFiles</param-name>  <param-value>false</param-value> </init-param> <init-param> <param-name>maxRequestSize<
the servlets
init parameters in web.xml as: <servlet> <servlet-name>...; </servlet> <context-param> <param-name>Email</param-name> <param-value>userEmail@gmail.com</param-value> <
java developer
;active.validservlet</servlet-class> <init-param> <param-name>...;/init-param> <init-param> <param-name>password</param-name> <param-value>rammohan</param-value> </init-param> <
Passing Parameter with <jsp: include>
:param name="UserName" value="Roseindia.net"/> </jsp
Lazy Load Application example in Wicket
; <init-param>    <param-name>applicationClassName<...;com.roseindia.wicket.LazyLoadApplication</param-value>    </init-param>    <init-param>   <param-name>debug</param
The Life cycle of An Applet
cycle on an applet. The init() method is basically called to read the PARAM tag... are the lifecycle methods of an Applet:  init(): This method is called... of the applet when applet is destroyed. init () method: The life cycle of an applet
how to execute the below servlet with html page
;active.validservlet</servlet-class> <init-param> <param-name>...;/init-param> <init-param> <param-name>password</param-name> <param-value>rammohan</param-value> </init-param> <
Servlet Context
the reference of the ServletContext to the context init parameters. The servlet and jsp... of the ServletContext. The Context init parameters are available to the entire web application not just to the single servlet like servlet init parameters. How can we
PHP SubString Function
( string $var , int $init [, int $len ] ) In the above format $var denotes the actual string from which the sub-string is to be extracted. $init... if the string is "roseindia" and the value of $init is 3 the the first
Introduction to RCFaces
,dataGrid </param-value> </init-param> <load-on-startup>1<...; <f:view> <html> <head> <vh:init /> </head>...; <context-param> <param-name>javax.faces.STATE_SAVING
Creating and Initializing a Servlet using Annotation
; <init-param>     <param-name>param1<...;  <param-value>value2</param-value>   </init...;); out.println("<br/>"); out.println("Init parameters
Spring Context Loader Servlet
;org.apache.struts.action.ActionServlet </servlet-class> <init-param> <param...-config.xml</param-value> </init-param> <init-param>...;/param-value> </init-param> <init-param> <param
"Hello World" example in Wicket
;    <param-value>2</param-value>   </init...    </filter-class>    <init-param>   <param-name>applicationClassName</param-name>  <

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.