Solved

The exception is not handled

Posted on 2002-06-04
6
164 Views
Last Modified: 2010-03-31
Why the following code get the error: "The exception java.lang.Exception is not handled."?

public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)         throws ServletException
{
     super.performTask(request, response);
    String cmdName = null;
    Command cmd = null;
    CommandMapObject mapObj = null;
     Result result = new Result();
     try{
          mapObj = this.getCmdMap().getCommandMapObject(this.getCmdName(request));
                  if (this.getCmdName(request).equalsIgnoreCase("login")){
                       this.login(request);
                       result.setTargetName("success");        
                  }else {
                       this.logout(request);
                          result.setTargetName("success");
                  }

                  forward(request, response, mapObj, result);
       
         } catch (SignOnException se) {
              result.setObject("errorMsg", se.getMessage());
              request = setRequestParameters(request, mapObj, result);
              result.setTargetName("fail");
              forward(request, response, mapObj, result);
         } catch (Exception e) {
                  throw new ServletException(e.getMessage());
         }
}
0
Comment
Question by:DevelHelper
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
pellep earned 50 total points
ID: 7054203
does the performTask() function in the superclass throw 'Exception'. If so, you need to catch it when you call super.performTask(request, response);
0
 

Author Comment

by:DevelHelper
ID: 7054275
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
    {
        performTask(request, response);
    }
0
 
LVL 4

Expert Comment

by:pellep
ID: 7054294
try

public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse
response)         throws ServletException
{

   
   String cmdName = null;
   Command cmd = null;
   CommandMapObject mapObj = null;
    Result result = new Result();
    try{
         super.performTask(request, response);
         mapObj = this.getCmdMap().getCommandMapObject(this.getCmdName(request));
                 if (this.getCmdName(request).equalsIgnoreCase("login")){
                      this.login(request);
                      result.setTargetName("success");        
                 }else {
                      this.logout(request);
                         result.setTargetName("success");
                 }

                 forward(request, response, mapObj, result);
       
        } catch (SignOnException se) {
             result.setObject("errorMsg", se.getMessage());
             request = setRequestParameters(request, mapObj, result);
             result.setTargetName("fail");
             forward(request, response, mapObj, result);
        } catch (Exception e) {
                 throw new ServletException(e.getMessage());
        }
}
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DevelHelper
ID: 7054318
I tried your code, but got the same compile error.
0
 
LVL 4

Expert Comment

by:pellep
ID: 7055714
doesn't the compile error include any indication as to where the error occured (filename, line-number or the likes)?
0
 
LVL 4

Expert Comment

by:pellep
ID: 7055723
it could also be the call to forward(request, response, mapObj, result);
within the first catch section.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now