Thread View: aus.computers.java
2 messages
2 total messages
Started by Tony F. White
Wed, 12 Jan 2000 00:00
finding out serlvet name?
Author: Tony F. White
Date: Wed, 12 Jan 2000 00:00
Date: Wed, 12 Jan 2000 00:00
20 lines
1412 bytes
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);
}
}
Re: finding out serlvet name?
Author: Chris Wolfe
Date: Tue, 11 Jan 2000 00:00
Date: Tue, 11 Jan 2000 00:00
30 lines
1824 bytes
1824 bytes
It has been a while since I was rooting through servlets, but it seems
to me that the HttpServletRequest.getServletPath method will get you
what you want. Remember that the same servlet instance could be shared
between more than one URL.
Chris
"Tony F. White" wrote:
>
> 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);
> }
> }
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads