Solved

The exception is not handled

Posted on 2002-06-04
6
163 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java 1603 Error 3 45
bigHeights  challenge 13 56
mergeTwo  challenge 13 72
Java / Linux and Regular Expressions 11 48
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 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

15 Experts available now in Live!

Get 1:1 Help Now