Diu Lee Lo Mo at [EMAIL PROTECTED] wrote:

> Dear Craig,
> 
>  Is that the servlet instance will be created once a
> request is coming in ? The target class will call
> init() when it is called at first time ?
> 
>  My whole picture is :
>  request -> target class -> init()

Yes, unless you don't specify that that servlet should be loaded at startup
(but that's a Container behavior, I believe). Can't you simply do something
like:

    public class MyServlet extends HttpServlet {
        private void String contextPath = null;

        public void init(...) {
            // do whatever you want but don't touch contextPath
            this.contextPath = null;
        }

        public void service(...) {
            if (this.contextPath == null) {
                // derive the context path from the request
                this.contextPath = ... ;
            }
            super.service(...);
        }

        ....
    }

Or you _NEED_ to have the context path in the INIT method (but I don't see
any reason WHY that would be needed).

    Pier

Reply via email to