Solved

The exception is not handled

Posted on 2002-06-04
6
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

739 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