my dog learned polymorphism*
The moose likes Servlets and the fly likes Using forward or include in a filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using forward or include in a filter" Watch "Using forward or include in a filter" New topic
Author

Using forward or include in a filter

Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Hi,

I have come across some security access filters which are using request.getRequestDispatcher(...).forward() and .include() from within the filter. If the user is not authorised, they get forwarded to an error page from within the filter.

Does this seem an acceptable technique to use or should we consider other options such as writing the html page from the filter?

The .include() is being used in one place to call in a servlet that does a bunch of checks and being used for other things too.

Regards

Faisal


The secret to creativity is knowing how to hide your sources.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Forwarding from a filter is fine.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Writing HTML in it is not.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Just to clarify guys, technique explained in the following article is not good way to go then:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets8.html#103101

Any views on using the .include()?

Thanks for the feedback thus far.
 
wood burning stoves
 
subject: Using forward or include in a filter
 
Similar Threads
Filter-mapping in web.xml error
Filter being called for Struts' forwarded JSP
regarding filters and RequestDispather
Question on Filters and RequestDispatcher
Count of hits to a site.