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

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

分类:Java 时间:2010-06-17 人气:158
分享到:
blog comments powered by Disqus

相关文章

  • mysql configuration file load order. precedence effect parameters 2011-05-24

    mysql configuration file and the parameter file load order priority in force, from high ----------> low 1, mysql start directly specify the specific parameters 2, mysql startup configuration file directly to the specified location, priority, time 3,

  • Description of the parameters of the configuration file Redis [turn] 2011-04-26

    A recent project used Redis to do data caching, using Redis most important thing is to write the configuration file, then to understand the meaning of its various configuration parameters, order a bit today and found that some parameters do not under

  • Vmx file of the virtual machine configuration file parameters to explain 2011-03-26

    From http://bbs.vmsky.com/thread-21676-1-1.html Thank tsunami_liao Share VMware parameters explain: http://sanbarrow.com/vmx.html Do not indiscriminate modify vmx file. Modify the vmx file before backup

  • pathinfo models need to open a php configuration file parameters 2011-07-14

    pathinfo mode on the following parameters need to php.ini cgi.fix_pathinfo = 1 But nginx environment, if the uri contains Chinese, PATH_INFO would be cut off, will produce a new ORIG_PATH_INFO, is correct, Mother, why do not directly use REQUEST_URI

  • Interpretation of the configuration file parameters Redis redis.conf 2010-11-29

    Transfer: http://blog.csdn.net/Java2King/archive/2010/07/22/5754476.aspx redis.conf configuration options are as follows daemonize the process is run after the table, the default is no After the process runs as Taiwan pidfile, you need to specify a p

  • Interpretation of the configuration file redis.conf parameters Redis 2010-11-29

    Turn: http://blog.csdn.net/Java2King/archive/2010/07/22/5754476.aspx redis.conf configuration options are as follows daemonize if a background process running, the default is no pidfile is running as a background process, you need to specify a pid, t

  • Java Properties file to read the six methods 2010-07-08

    Properties file using the J2SE API to read the six methods 1. Using the java.util.Properties class load () method example: InputStream in = lnew BufferedInputStream (new FileInputStream (name)); Properties p = new Properties (); p.load (in); 2. Use j

  • Java properties file to read [transfer] 2010-12-29

    Java properties file to read] [switch Use J2SE API methods to read documents in the six Properties 1. Using the java.util.Properties class load () method example: InputStream in = lnew BufferedInputStream (new FileInputStream (name)); Properties p =

  • Thread error, expert help, very grateful!!! Line waiting ..... 2010-09-13

    The realization of a regular automatic upload files to FTP function, but the thread error. TimeTask.java -------------------------------------------------- ---------- import java.util.TimerTask; public class TimeTask extends TimerTask ( ftpClient ftp

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.407 (s). 12 q(s)