• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with RequestDispatcher

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

See my servlet code.



While i am running the servlet, its telling that "cannot forword response/forward already coommited"

What is exact problem. I am creating RequestDispatcher when the condition is true only. if the first condition is true, the controller will go to the resource specified in the path. so no way to excute the remaining servlet. but its excuting. thats why its coming like that.(I think)

when i include return statement immediatly after forward method calling, its working fine. why its so.

please give the solution

thanks in advance.
Prasad
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a common issue.

The response.forward method does not halt execution of your servlet; neither does response.sendRedirect.

You need to either branch your code in such a way that no code is run after a forward or always add a return statement just after the call to forward.


[ December 16, 2005: Message edited by: Ben Souther ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic