sling-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@adobe.com>
Subject Re: request.getCharacterEncoding() always returns ISO-8859-1
Date Fri, 25 Feb 2011 16:06:35 GMT
Hi,

Am Freitag, den 25.02.2011, 08:52 +0000 schrieb Ian Boston: 
> Markus,
> 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)
> 
> and
> 
> Does registering against a null context make a Filter active on all contexts?

The Felix Http Service has whiteboard pattern support for servlet Filter
registration. So you just register your filter as a javax.servlet.Filter
service with an alias service property and you should be done.

Regards
Felix

> 
> TIA
> Ian
> 
> 
> 
> 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.joschko@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 <vidar@idium.no> wrote:
> >>> On Thu, Feb 10, 2011 at 11:56 PM, Peter Dotchev <dotchev@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 <vidar@idium.no> - http://www.idium.no
> >>> Sommerrogata 13-15, N-0255 Oslo, Norway
> >>> + 47 22 00 84 00
> >>> Quando omni flunkus moritatus!
> >>> 
> >> 
> 



Mime
View raw message