• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes my filter implements public abstract interface javax.servlet.Filter
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 26777
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic