servlet in the web.xml configuration file parameters in context-param and the init-param District

sponsored links
web.xml which can be defined two parameters:
(1) application within the parameters stored in servletcontext, in web.xml, configured as follows: <context-param>
<param-name> context / param </ param-name>
<param-value> avalible during application </ param-value>
</ Context-param>
(2) servlet context parameters, only the servlet's init () method to obtain, configure in web.xml as follows:

<servlet>
<servlet-name> MainServlet </ servlet-name>
<servlet-class> com.wes.controller.MainServlet </ servlet-class>
<init-param>
<param-name> param1 </ param-name>
<param-value> avalible in servlet init () </ param-value>
</ Init-param>
<load-on-startup> 0 </ load-on-startup>
</ Servlet>
In the servlet can access through the code are:

package com.wes.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class MainServlet extends HttpServlet (

public MainServlet () (
super ();
)
public void init () throws ServletException (
System.out.println ("The following two parameters param1 is stored in the servlet's");
System.out.println (this.getInitParameter ("param1"));
System.out.println ("The following parameters are stored in servletcontext in");
System.out.println (getServletContext (). GetInitParameter ("context / param"));
)
)

The first parameter in the servlet which can getServletContext (). GetInitParameter ("context / param") can only be the second parameter servlet's init () method by this.getInitParameter ("param1") to take
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of servlet in the web.xml configuration file parameters in context-param and the init-param District

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • Ruby on Rails Routing - Simple Examples

    This article contains a list of ruby on rails routing examples. If you find you have any questions please leave a comment. Routes are processed from the top of routes.rb down. If a route is matched it will stop processing the routes.rb file and use that r

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries