You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dave <dj...@maccormack.net> on 2013/07/17 19:38:07 UTC

Using addFilter and addServlet

I'm using Tomcat 7.0.42.  Most examples of ServletContext.addFilter() and 
ServletContext.addServlet() show it being used from a contextInitialized() 
event handler, however, the Servlet 3.0 spec doesn't limit the use of 
addServlet/addFilter to contextInitialized() (unless it is in there 
somewhere and I missed it).

I have successfully used addServlet() from the init() method of a Servlet 
(e.g. I've dynamically created several servlets from a servlet that I 
specify in a web.xml), however, I have not successfully been able to use
addFilter() from my Servlet init method (although I have done so from a 
contextInitialized event handler).

My questions are:

1) am I totally off the mark in thinking it is OK to use addServlet() from 
the the init() method of a Servlet?  Should I expect this feature to exist 
in future releases or is it a side-effect that could disappear at anytime?

2) should I be able to use addFilter() from an init() method or is that 
crazy.

Thanks,

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using addFilter and addServlet

Posted by Dave <dj...@maccormack.net>.
On Wed, 17 Jul 2013, Mark Thomas wrote:

> No problem. The expectation of the EG (this was before I was an EG
> member but I've chatted about this with Filip who was on the EG for
> Servlet 3.0) was that the adding was only for use during context start.
> There was some debate about adding during run-time but the conclusion
> was not to support that - I think due to potential complexity vs.
> benefit / minimal demand.
>

I can certainly understand that.  I'm speculating that using addServlet() 
from init() worked because of the Tomcat's support for lazy servlet init. 
There's no analogous notion for filters so they never had a chance.

> If you have a use case, feel free to open a Jira for the Servlet EG to
> consider for 3.2. Contact details should be in the 3.1 spec.
>

My use case is pretty simple.  I have a ``parent'' servlet that 
instantiates a number of ``child'' servlets (there's no real hierarchy 
here, once they're started they're all peers) based on the parent's 
<init-param> values (e.g. query a database, read configs from a dir, etc). 
And, I have multiple parents defined per web.xml file.

I have a reasonable work-around so it's not a big deal.  It would just be 
a little cleaner if I could do it the way I originally planned.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using addFilter and addServlet

Posted by Mark Thomas <ma...@apache.org>.
On 17/07/2013 19:14, Questiony McAskerton From Queryville wrote:
> On Wed, 17 Jul 2013, Mark Thomas wrote:
> 
>>
>> No, but not permitted by the spec.
>>
>> Mark
>>
> 
> Mark,
> 
> Thank you very much for the quick response.

No problem. The expectation of the EG (this was before I was an EG
member but I've chatted about this with Filip who was on the EG for
Servlet 3.0) was that the adding was only for use during context start.
There was some debate about adding during run-time but the conclusion
was not to support that - I think due to potential complexity vs.
benefit / minimal demand.

If you have a use case, feel free to open a Jira for the Servlet EG to
consider for 3.2. Contact details should be in the 3.1 spec.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using addFilter and addServlet

Posted by Questiony McAskerton From Queryville <dj...@maccormack.net>.
On Wed, 17 Jul 2013, Mark Thomas wrote:

>
> No, but not permitted by the spec.
>
> Mark
>

Mark,

Thank you very much for the quick response.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Using addFilter and addServlet

Posted by Mark Thomas <ma...@apache.org>.
On 17/07/2013 18:38, Dave wrote:
> 
> I'm using Tomcat 7.0.42.  Most examples of ServletContext.addFilter()
> and ServletContext.addServlet() show it being used from a
> contextInitialized() event handler, however, the Servlet 3.0 spec
> doesn't limit the use of addServlet/addFilter to contextInitialized()
> (unless it is in there somewhere and I missed it).
> 
> I have successfully used addServlet() from the init() method of a
> Servlet (e.g. I've dynamically created several servlets from a servlet
> that I specify in a web.xml), however, I have not successfully been able
> to use
> addFilter() from my Servlet init method (although I have done so from a
> contextInitialized event handler).
> 
> My questions are:
> 
> 1) am I totally off the mark in thinking it is OK to use addServlet()
> from the the init() method of a Servlet?

Yes.

> Should I expect this feature to exist in future releases

No.

> or is it a side-effect that could disappear at anytime?

Yes.

> 2) should I be able to use addFilter() from an init() method

No.

> or is that crazy.

No, but not permitted by the spec.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to disable session completely

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Daniel,

On 7/17/13 4:02 PM, Daniel NAZARKIEWICZ wrote:
> What is the procedure to disable entirely the session (JSESSIONID) 
> within tomcat 7 ?

Please don't hijack threads. If you would like to ask a new question,
create a new message to the list and don't reply to an existing one.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJR5v3jAAoJEBzwKT+lPKRYbtwP/jADLO1sKVBPZBI2/XdQHgTb
Aojzb3uuY5pddMP01MP7jCjTEPG+QLfN6QhlvvDAIkyQowDBz/9lr3uPPwNtisSD
RXuL1PMVTTpkXuV8mzCmZanrzpa8Ncwf9KS8iD9OqJweM9ifujtY7Si+9TvuZFeH
CFY5jL4h09dIixzwo6xYFRbRkzRF3E9FZ9zW/JhwukoKmwSv4tQkN0vkOaHqw+Rd
yj+qrP2rtqufWugmUM2AmGl3QQmhqmYu/L6bQFLudcbHdzhEZNsQAmgg4YAY7iyg
syrfdsmQ6/5yu+Hj8BEaocjlYx7IzwUqyfEj4K5QZHEjJ6MR6ZjYs6CC7+SCB3BJ
97iIX+5pyIjLuo6gyo3VUMZ4zrjs6S+15Z34DJaUeQVtC/dW9PLZm6M60JkMieeG
2cOSWUC97kMGpX7rwVXu7iamL+o1KKwhuY4x5JBYwxfiZzICFAhek1U0wQxXpbT5
RKFMyzBSRQ0+1FhE6+gtlGVuwCM1XLctvK3qONpr0qOX7J1ytsCAJ8sDQ8brAQg+
HysjKMH1c0wf6REHMcPqGhlBlc1WH+kf87MGa0kj59LASKeBPDvPt3x5qoqg3rMb
TDG0VpU+UgnJAZvmsxPnqjgGrwGlrbr1nfGq3VpI6c6GFPrISW5mW8Up5fdQEBgQ
K1RDPdNK7lacSW8qusCI
=YD5U
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


How to disable session completely

Posted by Daniel NAZARKIEWICZ <dn...@gmail.com>.
Hi,

What is the procedure to disable entirely the session (JSESSIONID) 
within tomcat 7 ?

Thank you

Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org