Share on Google+Share on Google+

chandrasekar
Init param
1 Answer(s)      9 years ago
Posted in : Java Beginners

What is the correct syntax of init param?

Ads

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...;[email protected]</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
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
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
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>
= "JSTLImportingDate.jsp"> <c:param name = "date" value = "<h1>So Have you
@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>
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
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads