Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 541
  • Last Modified:

finally block does not complete normally

hi
i am getting an error saying "finally block does not complete normally " ..,

in the below mentioned code , how to remove this ?

            try
            {
              response.sendRedirect("TechnicalDifficulties.jsp?err=Session Timeout");
            }
            catch(Exception exp) {
                  exp.getMessage();
            }
            finally
            {
                  return;
            }
      
0
mali_ini
Asked:
mali_ini
  • 2
3 Solutions
 
Irwin SantosComputer Integration SpecialistCommented:
Get rid of that finally block
0
 
deepaknetCommented:
A return in a finally block is a bad style of coding.
Simply because it "eats" all exceptions and errors that get thrown.

Check out this interesting discussion on the error message: http://www.codecomments.com/message514605.html
0
 
t_itaniumCommented:
hi  mali_ini

i think the finally is not executed properly because of this code in the try..

response.sendRedirect("TechnicalDifficulties.jsp?err=Session Timeout");


you r responding..redirecting..so you cannont then return.....i think you can put the return in the catch block..and in the try block.. ie:

  try
          {
             response.sendRedirect("TechnicalDifficulties.jsp?err=Session Timeout");
             return;
          }
          catch(Exception exp) {
               exp.getMessage();
               return;
          }

or..

  try
          {
             response.sendRedirect("TechnicalDifficulties.jsp?err=Session Timeout");
          }
          catch(Exception exp) {
               exp.getMessage();
               return;
          }

cause simply you don't need the return after redirecting..

cheers
       
0
 
Irwin SantosComputer Integration SpecialistCommented:
@pinaldave...my comment is valid, as it first points out the problem....deepaknet & t_itanium provided the detail.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now