Hi Ian,
> Side question, but related.
> I have tried in the past to register a Filter before the SlingMain Servlet 
> which also has Filter registration functionality (presumably from a time when 
> the OSGi HttpService didnt support filters), however I was always stuck 
> locating the HttpContext. (the Pax HttpService impl needs the a real 
> HttpContext class)
>
> Is the Context ID mentioned in [0], the service ID of the service that 
> implements the HttpContext? (which would be SlingMain as that implements 
> HttpContext and registers against itself)

I would guess so. The only ServletContext Service  I can quickly
identify in the console is the one from sling with the PID
org.apache.sling.engine.impl.helper.SlingServletContext
Using that as a contextId does not change anything. The servletcontext
I get is of type
org.apache.felix.http.base.internal.context.ServletContextImpl

>
> and
>
> Does registering against a null context make a Filter active on all contexts?

Admittedely I am not sure where to look after to verify that.
I see no difference using the above mentioned service PID as contextId
or using no contextId.

Regards,
 Markus



> On 24 Feb 2011, at 18:21, Julian Sedding wrote:
>
>> Hello Markus
>>
>> You can register servlet filters in Sling, but you can also register
>> servlet filters in the OSGi HttpService using the whiteboard[0]. As
>> the SlingMainServlet runs within the OSGi HttpService, you may have
>> more success registering a filter there. I don't know where in the
>> stack ParameterSupport is added, so YMMV. Let us know whether this
>> does the trick.
>>
>> Regards
>> Julian
>>
>> [0] 
>> http://felix.apache.org/site/apache-felix-http-service.html#ApacheFelixHTTPService-UsingtheWhiteboard
>>
>>
>>
>> On Thu, Feb 24, 2011 at 4:29 PM, Markus Joschko
>> <markus.josc...@gmail.com> wrote:
>>> Hi Vidar and all,
>>> I think that this approach is not working.
>>> I have the exact same use case. We don't want to put the _charset_
>>> parameter into every form. Therefore I tried to automatically add a
>>> _charset_ request parameter to the request in a filter.
>>> However that parameter never gets picked up as ParameterSupport is
>>> created before the filter gets called (and then uses the reference to
>>> the original servletrequest and not the wrapped one).
>>> I could theoretically reinstantiate Parametersupport but that requires
>>> knowledge of the servlet attribute key where parametersupport is
>>> stored. And that is a private variable in parametersupport.
>>>
>>> Any other chance to not have the _charset_ parameter in every post
>>> request sent to the system?
>>>
>>> Thanks,
>>>  Markus
>>>
>>> On Fri, Feb 11, 2011 at 2:25 PM, Vidar Ramdal <vi...@idium.no> wrote:
>>>> On Thu, Feb 10, 2011 at 11:56 PM, Peter Dotchev <dotc...@gmail.com> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Recently
>>>>> http://dotev.blogspot.com/2011/02/posting-non-ascii-characters-in-web.html
>>>>>  I
>>>>> stumbled  over this issue too.
>>>>>
>>>>> I don't want to add _charset_ input to all the forms.
>>>>> Is there a way to set the request encoding to UTF-8?
>>>>> IMHO it would be better if the request encoding is configurable like it is
>>>>> done in Wicket.
>>>>>
>>>>> http://wiki.apache.org/tomcat/FAQ/CharacterEncoding Tomcat FAQ  suggests
>>>>> using a filter.
>>>>> How can I do that in Sling?
>>>>
>>>> Hi, you can implement the javax.servlet.Filter interface and register
>>>> your implementation as a Filter service:
>>>>
>>>> @Component(immediate = true)
>>>> @Properties({
>>>>        @Property(name = "filter.scope", value = "request",
>>>> propertyPrivate = true),
>>>>        @Property(name = "filter.order", value = "-9", propertyPrivate = 
>>>> true)
>>>> })
>>>> @Services({@Service(javax.servlet.Filter.class)})
>>>> public class YourFilter implements javax.servlet.Filter {
>>>>  ...
>>>> }
>>>>
>>>>
>>>>
>>>> --
>>>> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
>>>> Sommerrogata 13-15, N-0255 Oslo, Norway
>>>> + 47 22 00 84 00
>>>> Quando omni flunkus moritatus!
>>>>
>>>
>
>

Reply via email to