servlet-filters

ClickJacking Filter to add X-FRAME-OPTIONS in response

社会主义新天地 提交于 2020-02-03 04:50:07
问题 In order to tackle clickJacking and blocking my site to be opened by iframe I have created a servlet filter in which I am adding below line to add "X-FRAME-OPTIONS" response header. But when I run page and see response headers of that page I never get this header in there. Any Idea why? public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ) throws IOException, ServletException { HttpServletResponse res = (HttpServletResponse)response; chain.doFilter

java.lang.IllegalArgumentException: Filter mapping must specify either a <url-pattern> or a <servlet-name>

狂风中的少年 提交于 2020-02-03 04:37:05
问题 I've created very simple REST app with next web.xml: <context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param> <listener> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> </listener> <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> </servlet> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>

Servlet filter wrapper - trouble changing content type

ε祈祈猫儿з 提交于 2020-01-30 05:06:56
问题 I have RESTful web service which is consumed by javascript. This service returns a content type of "application/json". However, for IE the content type must be "text/html". So I written a filter and wrapper to change the content type when IE is detected as the client. My logic seems to have no effect on the content type. What am I doing wrong? The filter: public class IE8Filter implements Filter { private Logger logger = LoggerHelper.getLogger(); @Override public void destroy() {} @Override

Servlet filter wrapper - trouble changing content type

谁说胖子不能爱 提交于 2020-01-30 05:06:48
问题 I have RESTful web service which is consumed by javascript. This service returns a content type of "application/json". However, for IE the content type must be "text/html". So I written a filter and wrapper to change the content type when IE is detected as the client. My logic seems to have no effect on the content type. What am I doing wrong? The filter: public class IE8Filter implements Filter { private Logger logger = LoggerHelper.getLogger(); @Override public void destroy() {} @Override

SocketTimeOut Exception in java whiile calling RestTemplate GetforObject

大城市里の小女人 提交于 2020-01-24 00:34:12
问题 we experience the following error pattern: I/O error on GET request for "https://samplepath": Timeout while fetching URL: https://samplepath; nested exception is java.net.SocketTimeoutException: Timeout while fetching URL: samplepath Code: RestTemplate restTemplate = new RestTemplate(); try { URI uri = new URI("https://samplepath); sessionInfo = restTemplate.getForObject(uri, SessionResponse.class); } catch (Exception e) { System.out.println(e.getMessage()); } This code is written inside the

What is the difference between a Servlet filter and a Jersey filter?

江枫思渺然 提交于 2020-01-23 18:05:15
问题 I read a lot of tutorials but I don't understand what are the differences between Servlet filters and Jersey filters. Anyone can exmplain me? 回答1: In Servlet container, you have Servlets and you have Servlet Filters. Generally, the Servlets handle processing of the request, and the Servlet Filter handles pre an post processing of the request. So a request flow looks like Request --> Filter --> Servlet --> Filter --> Response The Jersey application, it is implemented as a Servlet 1 . So in the

What is the difference between a Servlet filter and a Jersey filter?

怎甘沉沦 提交于 2020-01-23 18:02:59
问题 I read a lot of tutorials but I don't understand what are the differences between Servlet filters and Jersey filters. Anyone can exmplain me? 回答1: In Servlet container, you have Servlets and you have Servlet Filters. Generally, the Servlets handle processing of the request, and the Servlet Filter handles pre an post processing of the request. So a request flow looks like Request --> Filter --> Servlet --> Filter --> Response The Jersey application, it is implemented as a Servlet 1 . So in the

getSession() always creates a new session

我与影子孤独终老i 提交于 2020-01-23 02:17:12
问题 We have SecurityFilter class in our application by implementing Filter and our doFilter method looks like this. public void doFilter(ServletRequest sres, ServletResponse sreq, FilterChain chain) throws IOException, ServletException { LOGGER.debug(Logger.buildLogMessage("Starting SecurityFilter.doFilter")); HttpServletRequest request = (HttpServletRequest) sres; HttpServletResponse response = (HttpServletResponse) sreq; HttpSession session = request.getSession(); We have the following entry in

Servlet Filter url-mapping /* is not working on 404 errors

岁酱吖の 提交于 2020-01-22 01:50:07
问题 I'm using Resin Server & Apache 2.2 with virtual hosting. Here I'm facing a big challenge in calling a concrete filter. I'm having a generic Filter class to process all the incoming request. Ex: www.example.com/hello this hello is not calling the below filter instead it throwing file not found error(404). If "hello" is having a proper servlet mapping then the below filter is working. Web.xml : <filter> <filter-name>CorpFilter</filter-name> <filter-class>com.filter.CorpFilter</filter-class> <

Tomcat + ActiveJDBC: open/close connection using servlet filter?

佐手、 提交于 2020-01-17 05:51:04
问题 My web application uses ActiveJDBC. This ORM framework requires to open new DB connection with every new thread (and of course close it when the thread finishes). I am wondering if the best way to achieve this is to use a Web Filter. if this is the case, where do I call Base.open() ? the options are init() or doFilter() . also, if I plan to call Base.close() in destroy() , I need to know that indeed destroy() is always called at the thread termination, whether it is normal or abnormal. EDIT: