This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Query on Request Dispatcher. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Query on Request Dispatcher." Watch "Query on Request Dispatcher." New topic

Query on Request Dispatcher.

Viji Elango
Ranch Hand

Joined: Apr 25, 2006
Posts: 36
In my filter code, I'm checking whether it is downtime, and if it is the case, then I'm dispatching to another JSP.
But I'm facing problems here.

1. Can I use RequestDispatcher in my Filter code?
2. Is the Usage that I've followed is correct?

Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
it seems fine
just hit tomcat and run your app

SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
Viji Elango
Ranch Hand

Joined: Apr 25, 2006
Posts: 36
I'm getting error.
at weblogic.servlet.internal.RequestDispatcherImpl.forward(Ljavax.servle
t.ServletRequest;Ljavax.servlet.ServletResponse V(
at com.sgr.gss.web.filter.MaintenanceWindowFilter.doFilter(Ljavax.ser
vlet.ServletRequest;Ljavax.servlet.ServletResponse;Ljavax.servlet.FilterChain V

Can't understand where I'm wrong.
Viji Elango
Ranch Hand

Joined: Apr 25, 2006
Posts: 36
I'm getting the error, response already committed..

Any help please..
Bachi Taurean

Joined: Aug 03, 2006
Posts: 26
Hi viji,

You cant call filterChain.doFilter after you have done a forward, since by the time you call doFilter, the request and response objects are already in control of another web component.

Success is never ending and Failure is neve Final
Viji Elango
Ranch Hand

Joined: Apr 25, 2006
Posts: 36
Thanks for your reply..
I tried using SendRedirect.. But this time, my loop is running infinite..
Please help.
I agree. Here's the link:
subject: Query on Request Dispatcher.
Similar Threads
Filter to check if user is logged in
doubt with filters
getServletConfig() does not work
Help Needed in Filter Code
problem while giving a url pattern in filter mapping