In my doPost method I'm doing some thing in a try catch block.If some exception occurs i want it to redirect to some error page,using response.sendRedirect(some url).Before entering the try -catch block i'm checking for session,if session is null using the response.sendRedirect i'm redirecting to another page.Here it works.But in catch block it is not working(Plz check my code snipplet).Can some one tell me why my servlet behaves like this.
The first step in diagnosis would be to be sure that the redirect statement is even executed. Put in a System.out.println or log statement. You should also search your server logs. You may well be getting an IllegalStateException thrown by sendRedirect if the response has already written something out (since redirect involves a header, you can't redirect after the headers have been sent.) Bill
posted 15 years ago
Thanks William for that reply.
But i'm not getting any IllegalStateException thrown by sendRedirect.The scenario i'll explain.
I want to upload image files to server and i'm using the package from oreilly.
They got one constructor like MultipartRequest multipartrequest = new com.oreilly.servlet.MultipartRequest (req, tmpDir,LoginInit.UPLOAD_MAX_SIZE);
Here the UPLOAD_MAX_SIZE is set as 1 MB.I want to redirect to an error page when user tries to upload images of size larger than 1 MB.
The exception caught while uploading the image of larger size is IOException Error: Posted content length of 1297539 exceeds limit of 1048576.Instead of redirecting to the error page,its showing "Cannot find server".
The application server i'm using is jakarta-tomcat-3.3a(Older version).
Can someone shed some light into this.
Thanks & regards Chandrasekhar [ July 18, 2004: Message edited by: Chandrasekhar S ]
"Luck is when opportunity meets preparation"
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps