You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Viktors Krebss <lo...@delfi.lv> on 2001/08/03 10:21:25 UTC

ServletContext access question

Hello,

Does anyone know how can I access servlet init parameters form another
servlet ?
I mean I can access servlet context (<context-param> ) using
getServletContext().getContext("/some_servlet")
but what I need is to get into 
<servlet>...<init-param>param-I-need-to-know</init-param>...</servlet> .
Is it possible at all ?
Thanks for you help.

Regards,
--

Viktors Krebss, lopik@delfi.lv
SMC , http://www.smc.lv/
tel: +371-7777748, mob: +371-9243923, fax: +371-7777701

Re: ServletContext access question

Posted by Julien Gilli <da...@bigfoot.com>.
> but what I need is to get into 
> <servlet>...<init-param>param-I-need-to-know</init-param>...</servlet> .
> Is it possible at all ?

Did you look at the getInitParameter() method in the jdk doc ?

Julien Gilli.


Re: ServletContext access question

Posted by Viktors Krebss <lo...@delfi.lv>.

Bojan Smojver wrote:

> Maybe you can use application init parameters instead?
>
> Bojan
>
> Viktors Krebss wrote:
> >
> > Hello,
> >
> > Does anyone know how can I access servlet init parameters form another
> > servlet ?
> > I mean I can access servlet context (<context-param> ) using
> > getServletContext().getContext("/some_servlet")
> > but what I need is to get into
> > <servlet>...<init-param>param-I-need-to-know</init-param>...</servlet> .
> > Is it possible at all ?
> > Thanks for you help.
> >

Thanks for your reply.
Well, if no solution will come up I'll have to move everything to
context-params.
( what quite inconvenient for some reasons)
But still, does servlet API has such thing as accessing cross context init
params
or not ? Would be useful thing to know.

Regards,
--

Viktors Krebss, lopik@delfi.lv
SMC , http://www.smc.lv/
tel: +371-7777748, mob: +371-9243923, fax: +371-7777701



Re: ServletContext access question

Posted by Bojan Smojver <bo...@binarix.com>.
Maybe you can use application init parameters instead?

Bojan

Viktors Krebss wrote:
> 
> Hello,
> 
> Does anyone know how can I access servlet init parameters form another
> servlet ?
> I mean I can access servlet context (<context-param> ) using
> getServletContext().getContext("/some_servlet")
> but what I need is to get into
> <servlet>...<init-param>param-I-need-to-know</init-param>...</servlet> .
> Is it possible at all ?
> Thanks for you help.
> 
> Regards,
> --
> 
> Viktors Krebss, lopik@delfi.lv
> SMC , http://www.smc.lv/
> tel: +371-7777748, mob: +371-9243923, fax: +371-7777701

Re: AW: ServletContext access question

Posted by Viktors Krebss <lo...@delfi.lv>.

Thomas Bezdicek wrote:

> Why not use your own Generic Servlet where you read out parameters
> set them global and use it with "extend MyGenericServlet"?
> (use in web.xml <load-on-startup>1</load-on-startup> for the
> Generic servlet, so that it get the parameters before any other
> servlets start, and dont use at init super.init(ServletConfig)!!)
>
> hope it helps,
> tom
>
>

Thanks for your reply.
Sure, there are workarounds, like moving everything to global context.
Perhaps that question more about servlet API in general, and tomcat security
as well, is it possible at all or not. Have not found such information so far
.

Regards,
--

Viktors Krebss, lopik@delfi.lv
SMC , http://www.smc.lv/
tel: +371-7777748, mob: +371-9243923, fax: +371-7777701



AW: ServletContext access question

Posted by Thomas Bezdicek <th...@engnetworld.com>.
Why not use your own Generic Servlet where you read out parameters
set them global and use it with "extend MyGenericServlet"?
(use in web.xml <load-on-startup>1</load-on-startup> for the 
Generic servlet, so that it get the parameters before any other
servlets start, and dont use at init super.init(ServletConfig)!!)

hope it helps,
tom

> -----Ursprungliche Nachricht-----
> Von: Viktors Krebss [mailto:lopik@delfi.lv]
> Gesendet: Freitag, 3. August 2001 10:21
> An: tomcat-user@jakarta.apache.org
> Betreff: ServletContext access question
> 
> 
> Hello,
> 
> Does anyone know how can I access servlet init parameters form another
> servlet ?
> I mean I can access servlet context (<context-param> ) using
> getServletContext().getContext("/some_servlet")
> but what I need is to get into 
> <servlet>...<init-param>param-I-need-to-know</init-param>...</servlet> .
> Is it possible at all ?
> Thanks for you help.
> 
> Regards,
> --
> 
> Viktors Krebss, lopik@delfi.lv
> SMC , http://www.smc.lv/
> tel: +371-7777748, mob: +371-9243923, fax: +371-7777701