Handerson,
Valeu mas, oque estou querendo eh que meu servlet encontre um
determinado arquivo de configuracoes no servidor. Pex.: nesse arquivo
(que tem um nome especifico)constam usuario de conexao, url e classe
para conexao com SGBD (eh um .ini), isso o visa nao haver manutencao no
codigo quando houvesse alguma manutencao ou mudanca nos servidores.
Ainda nao sei se fui claro, eh como se o servlet necessitasse de um
arquivo de inicializacao onde estariam as "partes" passiveis de
mudanca.:)
Obrigado pela atencao e qualquer novidade ou duvida sobre a questao eh
soh entrar em contato.
Heider
>Ol� Heider
>
>se entendi bem, voc� que saber o endere�o relativo... veja em anexo um
>c�digo fonte de um servlet que vem com o JRun.. Nele existem v�rios
>m�todos que podem ser usados. Um deles deve resolver o seu problema.
>
>[]'s
>
>Handerson
>
>/*
> * @(#)SnoopServlet.java 1.16 97/05/22
> *
> * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
> *
> * This software is the confidential and proprietary information of Sun
> * Microsystems, Inc. ("Confidential Information"). You shall not
> * disclose such Confidential Information and shall use it only in
> * accordance with the terms of the license agreement you entered into
> * with Sun.
> *
> * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
>THE
> * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE
> * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
> * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY
DAMAGES
> * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
> * THIS SOFTWARE OR ITS DERIVATIVES.
> *
> * CopyrightVersion 1.0
> */
>
>import java.io.*;
>import java.util.*;
>
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>import sun.security.x509.*;
>
>
>/**
> * Snoop servlet. This servlet simply echos back the request line and
> * headers that were sent by the client, plus any HTTPS information
> * which is accessible.
> *
> * @version 1.16, 05/22/97
> * @author David Connelly
> */
>public
>class SnoopServlet extends HttpServlet {
>
> public void doGet (HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException
> {
> res.setContentType("text/html");
> ServletOutputStream out = res.getOutputStream();
> out.println("<html>");
> out.println("<head><title>Snoop Servlet</title></head>");
> out.println("<body>");
>
> out.println("<h1>Requested URL:</h1>");
> out.println("<pre>");
> out.println (HttpUtils.getRequestURL (req).toString ());
> out.println("</pre>");
>
> Enumeration enum = getServletConfig().getInitParameterNames();
> if (enum != null) {
> boolean first = true;
> while (enum.hasMoreElements()) {
> if (first) {
> out.println("<h1>Init Parameters</h1>");
> out.println("<pre>");
> first = false;
> }
> String param = (String) enum.nextElement();
> out.println(" "+param+": "+getInitParameter(param));
> }
> out.println("</pre>");
> }
>
> out.println("<h1>Request information:</h1>");
> out.println("<pre>");
> print(out, "Request method", req.getMethod());
> print(out, "Request URI", req.getRequestURI());
> print(out, "Request protocol", req.getProtocol());
> print(out, "Servlet path", req.getServletPath());
> print(out, "Path info", req.getPathInfo());
> print(out, "Path translated", req.getPathTranslated());
> print(out, "Query string", req.getQueryString());
> print(out, "Content length", req.getContentLength());
> print(out, "Content type", req.getContentType());
> print(out, "Server name", req.getServerName());
> print(out, "Server port", req.getServerPort());
> print(out, "Remote user", req.getRemoteUser());
> print(out, "Remote address", req.getRemoteAddr());
> print(out, "Remote host", req.getRemoteHost());
> print(out, "Authorization scheme", req.getAuthType());
> out.println("</pre>");
>
> Enumeration e = req.getHeaderNames();
> if (e.hasMoreElements()) {
> out.println("<h1>Request headers:</h1>");
> out.println("<pre>");
> while (e.hasMoreElements()) {
> String name = (String)e.nextElement();
> out.println(" " + name + ": " + req.getHeader(name));
> }
> out.println("</pre>");
> }
>
> e = req.getParameterNames();
> if (e.hasMoreElements()) {
> out.println("<h1>Servlet parameters (Single Value
>style):</h1>");
> out.println("<pre>");
> while (e.hasMoreElements()) {
> String name = (String)e.nextElement();
> out.println(" " + name + " = " +
>req.getParameter(name));
> }
> out.println("</pre>");
> }
>
> e = req.getParameterNames();
> if (e.hasMoreElements()) {
> out.println("<h1>Servlet parameters (Multiple Value
>style):</h1>");
> out.println("<pre>");
> while (e.hasMoreElements()) {
> String name = (String)e.nextElement();
> String vals[] = (String [])
>req.getParameterValues(name);
> if (vals != null) {
> out.print("<b> " + name + " = </b>");
> out.println(vals[0]);
> for (int i = 1; i<vals.length; i++)
> out.println(" " + vals[i]);
> }
> out.println("<p>");
> }
> out.println("</pre>");
> }
>
> String cipherSuite = (String)
> req.getAttribute ("javax.net.ssl.cipher_suite");
>
> if (cipherSuite != null) {
> X509Cert certChain [] = (X509Cert [])
> req.getAttribute ("javax.net.ssl.peer_certificates");
>
> out.println ("<h1>HTTPS Information:</h1>");
> out.println("<pre>");
>
> out.println ("Cipher Suite: " + cipherSuite);
>
> if (certChain != null) {
> for (int i = 0; i < certChain.length; i++) {
> out.println ("client cert chain [" + i + "] = "
> + certChain [i].toString ());
> }
> }
>
> // javax.net.ssl.session --> ssl.Session object
> // ... has above data plus creation and last used dates
>
> out.println("</pre>");
> }
>
>
> out.println("</body></html>");
> }
>
> private void print(ServletOutputStream out, String name, String
>value)
> throws IOException
> {
> out.print(" " + name + ": ");
> out.println(value == null ? "<none>" : value);
> }
>
> private void print(ServletOutputStream out, String name, int value)
> throws IOException
> {
> out.print(" " + name + ": ");
> if (value == -1) {
> out.println("<none>");
> } else {
> out.println(value);
> }
> }
>
> private static final String UNKNOWN = "<unknown>";
>
> public String getServletInfo() {
> return "A servlet that shows the request headers sent by the
>client";
> }
>}
>
>
>
>Heider Maciel wrote:
>>
>> Caros,
>>
>> Tenho que acessar do servlet um determinado arquivo, mas nao sei onde
>> ele esta. Gostaria de pegar o dirtetorio onde o servlet esta sendo
>> executado ou o path. Alguma dica???
>>
>> Obridado,
>>
>> Heider
>> Get Your Private, Free Email at http://www.hotmail.com
>> * Para n�o receber mais e-mails desta lista envie um e-mail para
[[EMAIL PROTECTED]]
>> e no corpo do email escreva [unsubscribe <seu-email>]
>
>--
>**********************************************************
>Handerson Ferreira Gomes, Analista de Sistemas
>CITS - Centro Internacional de Tecnologia de Software
>Depto: CNTS - Centro de Novas Tecnologias de Software
>Parque de Software de Curitiba
>81230-000 Curitiba, PR, Brasil
>+55 41 317 2086, fax: 337 1002
>http://www.cits.br
>**********************************************************
>
Get Your Private, Free Email at http://www.hotmail.com
* Para nao receber mais e-mails da lista, acesse
<http://www.sun.com.br:8080/guest/RemoteAvailableLists>, coloque seu e-mail, escolha a
lista <[EMAIL PROTECTED]> e de um <submit>.