Hello Bo,


Sunday, June 17, 2001, 10:47:09 PM, you wrote:

BX> "Andrew V. Zhdanov" wrote:

>> Hi, i do study Servlet Specification version 2.3 and i do like very much the
>> HttpSessionListener concept: there (for those who does not know) we can use
>> createSession event and destroySession event for managing session. Naturaly
>> i'd like to create a new instance of MyDocument class on createSession
>> event. But it (MyDocuemnt) needs SessionConfig for getInitParameters - but
>> all that i have in HttpSesionEvent (Servlet API class) is HttpSession.
>> Question is: How could i get ServletConfig from HttpSession or in any other
>> way, but MyDocument does not extends HttpServlet.
>> Could smb help me? Is anybody interested at it?
>> Best Regards.
>> [...]

BX> Hi :-)  I suggest you try the following:

BX>     public void sessionCreated(HttpSessionEvent e){
BX>         ...
BX>         HttpSession session=e.getSession();
BX>         ServletContext  sctx= session.getServletContext();
BX>         sctx.getInitParameter(...);
BX>         ...
BX>     }

That looks very fine, tnx, but there is no
HttpSession.getServletContext() method (or am i blind, pls tell me is
it so?)))). and there is getSessionContext method but is deprecated and
absolutely useless(((

BX> But with the above code, ServletContext.getInitParameter(...) will be
BX> used( Not ServletConfig/GenericServlet.getInitParameter(...) )

BX> [...]

BX> - ServletContext.getInitParameter(...)
BX>    I am not sure where I can define it and which tag I can use to define it?
BX>    % in TOMCAT_HOME/conf/server.html  ? OR  in WEB-INF/web.xml ?
BX>    % which "tag" I can use?

And from the "following emails" i've got that for
ServletContext.getInitParameter we can use the following to set it
(paramters) in web.xml surely:
<web-app>
    .....
    <servlet>
        ....
        <!-- that is for ServletConfig.getInitParameter -->
        <init-param>
         <param-name>db.password</param-name>
         <param-value>avalez</param-value>
        </init-param>
        ....
    </servlet>
    ......
    <!-- and that is for ServletContext.getInitParameter -->
    <context-param>
         <param-name>style.xsl</param-name>
         <param-value>/style.xsl</param-value>
    </context-param>
    ......
</web-app>

BX> [...]

And so, how could we get any(context or config) Init-Paramters from
HttpSession)))

--
Best regards,
 Andrew

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to