• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why doPost() of HttpServlet commits response?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here I am getting IllegalStateException here. I can guess, it is because doPost() of HttpServlet is already commiting response. But why it is so?

Thanks.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you calling super.doPost()?
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
Why are you calling super.doPost()?


Actually, WSAD generated it automatically, and because I was not knowing the insides, so I kept it as it is...

My doubt is, why it commits the response???

Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your servlet doesn't implement doPost and someone makes a post request to it, the container will let them know that this type of request is not supported by throwing a servletException with a meaningful message.

To change this behaviour, you override doPost and add your own code.
There is really no point in calling super.doPost.
[ December 01, 2005: Message edited by: Ben Souther ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Withour going into the details, I was also thinking what Ben said.

There is really no point in calling super.doPost.

Well there can be, but only if you know why you're doing it. For example we had a abstract Servlet once which did some generic processing, but if I remember correctly we designed it a bit diferently so it wasn't as good a story as I'd hoped
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should have qualified that.
There's almost no reason to call super.doPost.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got to override the doPost method with public access modifier.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic