This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read values after request.dispatch() or sendRedirect?

 
satish kinikiri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my filter i have requirement of showing user a message with ok cancel option.
if the user opts for ok then i have continue to the filter chain, if user opts for cancel then i need to redirect him some other page say error.jsp
I am trying as shown below

public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {


String url = "/jsp/message.jsp";
/*HttpServletResponse httpRes = (HttpServletResponse)response;
httpRes.sendRedirect(url);*/

RequestDispatcher requestDispatcher = request.getRequestDispatcher(url);
requestDispatcher.forward(request, response);
if(gotOKfrom message.jsp){
return or chain.doFilter(request, response);

} if( got cancel from message.jsp){

RequestDispatcher requestDispatcher = request.getRequestDispatcher("error.jsp");
requestDispatcher.forward(request, response);

}


System.out.println("am here returned..");
/chain.doFilter(request, response);
}




*****************

Please let me how to read what option user has selected from message.jsp

thanks
Advance
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the logic you are trying to do in a Filter belongs in a servlet.

Bill
 
satish kinikiri
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes my filter implements public abstract interface javax.servlet.Filter
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot interrupt the filter chain to obtain input form the user. As William indicated, you'll need to use another approach.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can forward or redirect a request from a filter. It's the part about expecting the subsequent request to come back into the filter and continue where the previous request left off which it doesn't work like that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic