Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

upload file failed sendRedirect not working correctly

 
Keng-Min Lin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the multipart/form-data in JSP page A, trying to upload an image file to my server.




In servlet B, I checked the header to limit the image size :


I expected it would be redirected back to page A if file is too large, but instead it was redirected back to Servlet B and keep repeating until the browser showed "ERR_CONNECTION_RESET";

I checked my access_log: it shows something like

"POST {path for servlet B} HTTP/1.1" 302 -
"POST {path for servlet B} HTTP/1.1" 302 -
"POST {path for servlet B} HTTP/1.1" 302 -

I have no clue what happened and don't know where to dig out more information for debugging
can anyone help?
thanks a lot~


updated:
do some experiment: do not sendRedirect but just return


access_log:
"POST {path for servlet B} HTTP/1.1" 200 -
"POST {path for servlet B} HTTP/1.1" 200 -
"POST {path for servlet B} HTTP/1.1" 200 -

looks like the problem is not about sendRedirect


any suggestion?
 
Samar Land
Ranch Hand
Posts: 60
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did your file is uploaded to the location that you want?
 
Keng-Min Lin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, if I upload some file within the size limit, the file is uploaded to the location I want.
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope you aren't expecting to redirect when a file upload has reached a certain size limit. HTTP doesn't work that way.

When an HttpServletRequest runs, the entire fire has already been transferred. It doesn't run concurrently with the upload.

You can set a limit on how much data will be accepted in web.xml, and that will cause the data to be rejected before your application code gets run. I'm not sure if it's smart enough to forcibly shut down the incoming network connection immediately or if it simply keeps going and discards the data. In either case, however, that won't allow you to redirect in application code, because the application code, like I said, only gets control after the webapp server has already accepted and cached the data.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic