• Post Reply Bookmark Topic Watch Topic
  • New Topic

strange filter behavior  RSS feed

 
Steve Mutonshi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented a servlet like

***
public void doFilter(ServletRequest servletReq, ServletResponse servletRes,
FilterChain filterChain) {

if(condition 1) {
filterChain.doFilter();
} else if(condition 2) {
req.getRequestDispatcher(..).forward(req, res);
} else {
do Filter2(servletReq, servletRes, filterChain);
}
}

public void doFilter2(ServletRequest servletReq, ServletResponse servletRes, FilterChain filterChain) {
...
filterChain.doFilter(servletReq, servletRes);
}

********************************

This is my only filter and it applies to all servlet and jsp. If "condition 1" is met, I want it directly go to destination page.
If "condition 2" is met, I want it forward to another page;
otherwise, I continue the filter logics in another method "doFilter2".

What is causing trouble is the "filterChain.doFilter()" in the 2nd method "doFilter2". Sometimes it does not work well. it sometimes gives me

java.net.SocketException: Connection reset by peer: socket write error

Do I have to split this "doFilter" and "doFilter2" into two Filter classes and let "doFilter2"'s logics reside in the second filter ? Is there anything fundamentally wrong with my current approach of using one filter ?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!