🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #939

finding out serlvet name?

#939
From: Tony F. White
Date: Wed, 12 Jan 2000 00:00
20 lines
1412 bytes
Does anyone know how you can find out the name of the current servlet you
are in.
and not just the classname (getClass().getName())
I am sure there has to be a better way because if you look at the log of the
web server they print out
[Date + Time ETC] alias/classname : message
I can do it by using the following but it causes all the servlets to call
their init() method.

    ServletContext context = getServletContext();
    Enumeration names = context.getServletNames();
    String name;
    while (names.hasMoreElements()) {
      name = (String)names.nextElement();
      if (this.equals(context.getServlet(name))) {
        log("wahoo: " + name);
      } else {
        log("Not this one: " + name);
      }
    }
Technical Details
Message-ID: <387bc8b7_2@news.ausmail.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,37435f9672022420
X-Google-Attributes: gid10d6db,public
X-Google-Thread: f5d71,37435f9672022420
X-Google-Attributes: gidf5d71,public
X-Google-Thread: 10a146,37435f9672022420
X-Google-Attributes: gid10a146,public
From: "Tony F. White" <tony@worldlingo.com>
Subject: finding out serlvet name?
Date: 2000/01/12
Message-ID: <387bc8b7_2@news.ausmail.com>
X-Deja-AN: 571414447
X-Trace: 12 Jan 2000 10:20:07 +1000, 210.9.46.50
X-MSMail-Priority: Normal
X-Priority: 3
Newsgroups: aus.computers.java,comp.lang.java,comp.lang.java.programmer
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300