Actually there's a more direct method in
javax.servlet.ServletContext.getServerInfo().
Check it out:
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContex
t.html
Hope this helps.
-----Original Message-----
From: Heath, Joseph [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 09, 2001 5:22 AM
To: '[EMAIL PROTECTED]'
Subject: RE: getting the ServerName
Your classes will not know where they are being run..
You have to pass some kind of context in to them..
I normally use a ref to the servlet through the constructor
eg..
public class MyExample {
private HttpServlet context;
public MyExample(HttpServlet context) {
this.context = context;
}
public void doSomething() {
String name = context.getServletName();
}
}
........
In the servlet
MyExample eg = new MyExample(this);
> -----Original Message-----
> From: Kazi the P i R @ t {- [mailto:[EMAIL PROTECTED]]
> Sent: 09 August 2001 11:11
> To: [EMAIL PROTECTED]
> Subject: getting the ServerName
>
>
> how can one of my packages (not a servlet) access the
> server's name?? I
> attempted to use the HttpServletRequest object in isolation
> and using the
> function getServletName() to achieve my goals... but it
> failed. It was just
> a shot in the dark...
>
> Now i am turning to you all... shed some light on my target
>
> including
> Thank Yous In Advance
>
> kazi
>