This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 61106
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using forward or include in a filter