• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About committed response and stuff...

 
Adrian Muscalu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet that acts strange and I don't know what might be the cause. I've simplified it to be easily understandable.
I have a doPost that does the following:

This is how methodA looks like:

This is how methodB looks like:

If IOException is thrown in methodA at line #2, methodB() will be executed. So far so good. After the execution of methodB() nothing happens. I checked the committed ststus before calling methodB() and after and the values look normal (false and true). What happened with my forward?
What is wrong in this picture? Can you guys give me an idea?
Thanks in advance,
Adrian
[ November 28, 2002: Message edited by: Adrian Muscalu ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to reorganise the 'do stuff here that causes an IOException', so that it has as little a chance of failing as possible.
If you have a block that outputs to the client, as soon as the output buffer is full (usually 8k) the response gets sent and is committed. You can't forward somewhere else at this point.
The Model-View-Controller helps a lot. Since all of the processing that is likely to fail is managed by the model and happens before the view starts, you always have the option of continuing or not.
Dave
 
Adrian Muscalu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
You need to reorganise the 'do stuff here that causes an IOException', so that it has as little a chance of failing as possible.
If you have a block that outputs to the client, as soon as the output buffer is full (usually 8k) the response gets sent and is committed. You can't forward somewhere else at this point.
The Model-View-Controller helps a lot. Since all of the processing that is likely to fail is managed by the model and happens before the view starts, you always have the option of continuing or not.
Dave

You are correct, my problems started the moment line#2 throwed an exception. I still don't understand how.
Correct. My request contains an uploaded file. If the size of the file is bigger than the value accepted by the MultipartParser constructor (O'Reilly) it throws an IOException. If I could only check the size of the file before the constructor...
I assume that when I try to forward using RequestDispatcher, the uploaded file will still "travel" back to the client, am I right?
I could really use a good book on MVC, with some practical example. Can you reccomend one?
Thank you,
Adrian
[ November 29, 2002: Message edited by: Adrian Muscalu ]
[ November 29, 2002: Message edited by: Adrian Muscalu ]
 
Adrian Muscalu
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem has been solved. Apparently there was a bug that Paul Wetzel explained long time ago.
Here is the link:
http://www.coderanch.com/t/347482/Servlets/java/com-oreilly-servlet-MultipartRequest-weirdness
Adrian
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Wetzel's message is from september-2000 and the last version of the com.oreilly.servlet package is dated Nov-5 2002.
Is the bug still there?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic