Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

The exception is not handled

Posted on 2002-06-04
6
Medium Priority
?
192 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 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
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

604 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