java - How to make a filter to detect if the user requested a page that is not found? -


i want create filter in app such before each request, detects whether requested page exists. if doesn't exist, forward user error page.

how detect page exists?

i need solution filter , not using web.xml tag method.

if don't have authentication, can.

  1. make filter
  2. use httpservletresponsewrapper , override senderror() , setstatus()
  3. pass wrapped response through chain.dofilter(req, wrapper)
  4. if senderror() in wrapper, see if it's 404.
  5. take appropriate response.

you may have override getoutputstream() , getwriter() avoid response flushed client before chance stuff.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -