You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by friday <fr...@logoclean.com> on 2013/08/14 15:39:40 UTC
@WebFilter did not trigger on OPTIONS Request
Hi,
I created a filter to handle the CORS stuff, but it is not triggered on
OPTIONS request. All other requests all filtered well.
My Environment is: tomee+ 1.6.0-SNAPSHOT
My filter class:
@WebFilter("/*")
public class CORSFilter implements Filter {
public CORSFilter() {
}
public void init(FilterConfig fc) throws ServletException {
}
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException,
ServletException {
HttpServletResponse r = (HttpServletResponse) response;
r.setHeader("Access-Control-Allow-Origin", "*");
r.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE,
OPTIONS");
r.setHeader("Access-Control-Allow-Credentials", "true");
r.setHeader("Access-Control-Allow-Headers", "accept, origin,
content-type");
chain.doFilter(request, response);
}
}
--
View this message in context: http://openejb.979440.n4.nabble.com/WebFilter-did-not-trigger-on-OPTIONS-Request-tp4664644.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: @WebFilter did not trigger on OPTIONS Request
Posted by friday <fr...@logoclean.com>.
Now I am trying something in conf/web.xml of tomee. Yes, it is a little bit
hard to figure out which settings should be done by application vs.
application server.
--
View this message in context: http://openejb.979440.n4.nabble.com/WebFilter-did-not-trigger-on-OPTIONS-Request-tp4664644p4664658.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: @WebFilter did not trigger on OPTIONS Request
Posted by Romain Manni-Bucau <rm...@gmail.com>.
It is explained in the page, either your web.xml or the global one (in conf
IIRC)
Le 15 août 2013 12:33, "friday" <fr...@logoclean.com> a écrit :
> I will try the tomcat filter. How can I enable / configure it?
>
> Extensions in openejb-jar... or separate web.xml?
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/WebFilter-did-not-trigger-on-OPTIONS-Request-tp4664644p4664656.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
Re: @WebFilter did not trigger on OPTIONS Request
Posted by friday <fr...@logoclean.com>.
I will try the tomcat filter. How can I enable / configure it?
Extensions in openejb-jar... or separate web.xml?
--
View this message in context: http://openejb.979440.n4.nabble.com/WebFilter-did-not-trigger-on-OPTIONS-Request-tp4664644p4664656.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: @WebFilter did not trigger on OPTIONS Request
Posted by Romain Manni-Bucau <rm...@gmail.com>.
PS: trunk should have a built in CORS filter -->
http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/8/14 Romain Manni-Bucau <rm...@gmail.com>
> Hi
>
> do you have a project (client+server) reproducing it?
>
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/8/14 friday <fr...@logoclean.com>
>
>> Hi,
>>
>> I created a filter to handle the CORS stuff, but it is not triggered on
>> OPTIONS request. All other requests all filtered well.
>>
>> My Environment is: tomee+ 1.6.0-SNAPSHOT
>>
>> My filter class:
>>
>> @WebFilter("/*")
>> public class CORSFilter implements Filter {
>>
>> public CORSFilter() {
>> }
>>
>> public void init(FilterConfig fc) throws ServletException {
>> }
>>
>> public void destroy() {
>> }
>>
>> public void doFilter(ServletRequest request, ServletResponse response,
>> FilterChain chain) throws IOException,
>> ServletException {
>>
>> HttpServletResponse r = (HttpServletResponse) response;
>> r.setHeader("Access-Control-Allow-Origin", "*");
>> r.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT,
>> DELETE,
>> OPTIONS");
>> r.setHeader("Access-Control-Allow-Credentials", "true");
>> r.setHeader("Access-Control-Allow-Headers", "accept, origin,
>> content-type");
>>
>> chain.doFilter(request, response);
>> }
>> }
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/WebFilter-did-not-trigger-on-OPTIONS-Request-tp4664644.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>
>
Re: @WebFilter did not trigger on OPTIONS Request
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
do you have a project (client+server) reproducing it?
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/8/14 friday <fr...@logoclean.com>
> Hi,
>
> I created a filter to handle the CORS stuff, but it is not triggered on
> OPTIONS request. All other requests all filtered well.
>
> My Environment is: tomee+ 1.6.0-SNAPSHOT
>
> My filter class:
>
> @WebFilter("/*")
> public class CORSFilter implements Filter {
>
> public CORSFilter() {
> }
>
> public void init(FilterConfig fc) throws ServletException {
> }
>
> public void destroy() {
> }
>
> public void doFilter(ServletRequest request, ServletResponse response,
> FilterChain chain) throws IOException,
> ServletException {
>
> HttpServletResponse r = (HttpServletResponse) response;
> r.setHeader("Access-Control-Allow-Origin", "*");
> r.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT,
> DELETE,
> OPTIONS");
> r.setHeader("Access-Control-Allow-Credentials", "true");
> r.setHeader("Access-Control-Allow-Headers", "accept, origin,
> content-type");
>
> chain.doFilter(request, response);
> }
> }
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/WebFilter-did-not-trigger-on-OPTIONS-Request-tp4664644.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>