Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query on Request Dispatcher.

 
Viji Elango
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it seems fine
just hit tomcat and run your app
 
Viji Elango
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting error.
javax.servlet.ServletException
at weblogic.servlet.internal.RequestDispatcherImpl.forward(Ljavax.servle
t.ServletRequest;Ljavax.servlet.ServletResponse V(RequestDispatcherImpl.java:33
4)
at com.sgr.gss.web.filter.MaintenanceWindowFilter.doFilter(Ljavax.ser
vlet.ServletRequest;Ljavax.servlet.ServletResponse;Ljavax.servlet.FilterChain V
(MaintenanceWindowFilter.java:109)

Can't understand where I'm wrong.
 
Viji Elango
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting the error, response already committed..

Any help please..
 
Bachi Taurean
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Viji Elango
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply..
I tried using SendRedirect.. But this time, my loop is running infinite..
Please help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic