Its depends on whether Kazi meant getServerName() or getServletName() .. I
was assuming he made a spelling mistake (its a frequent compiler warning on
my box) ..
As you cant get access to the Servlet through the ServletContext (deprecated
and doesn't work anymore)...
But if you want the ServerName yes do that...;-)
> -----Original Message-----
> From: Mills, Theo [mailto:[EMAIL PROTECTED]]
> Sent: 09 August 2001 14:37
> To: '[EMAIL PROTECTED]'
> Subject: RE: getting the ServerName
>
>
> 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
> >
>