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
> 

Reply via email to