My favorites
▼
|
Sign in
lineadecodigo
Web Code Samples in spanish
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
lineadecodigo_servlet
/
src
/
com
/
lineadecodigo
/
java
/
servlet
/
ParametrosInicio.java
r478
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.lineadecodigo.java.servlet;
/**
* @file ParametrosInicio.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 26-marzo-2011
* @url http://lineadecodigo.com/java/leer-parametros-de-inicializacion-de-un-servlet/
* @description Servlet que obtiene los parámetros del fichero de configuración
*/
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ParametrosInicio extends HttpServlet {
private static final long serialVersionUID = 1L;
private String _nivelLog;
private int _numeroPeticiones;
public ParametrosInicio() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out;
out = response.getWriter();
response.setContentType("text/html");
out.println("<html>");
out.println("<head><title>Valor parametros inicialización</title></head>");
out.println("<body>");
out.println("<h1>Valor parametros inicialización</h1>");
out.println("Nivel Log: " + _nivelLog + "<br/>");
out.println("Numero Peticiones: " + _numeroPeticiones);
out.println("<br><br><hr>");
out.println("Artículo disponible en: <a href=''></a><br/><a href='http://lineadecodigo.com/java/leer-parametros-de-inicializacion-de-un-servlet/' title='Linea de Codigo'>http://lineadecodigo.com/java/leer-parametros-de-inicializacion-de-un-servlet/</a>");
out.println("</body></html>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
public void init(ServletConfig config){
try{
_nivelLog = config.getInitParameter("NivelLog");
_numeroPeticiones = Integer.parseInt(config.getInitParameter("NumeroPeticiones"));
} catch(NullPointerException npe){
npe.printStackTrace();
}
}
}
Show details
Hide details
Change log
r352
by vcuervo on Mar 26, 2011
Diff
Parametros de Inicio
Go to:
...rvlet/WebContent/WEB-INF/web.xml
...va/servlet/ParametrosInicio.java
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 2147 bytes, 61 lines
View raw file
Powered by
Google Project Hosting