Solved

The exception is not handled

Posted on 2002-06-04
6
167 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 41
tomcat administrtor 12 47
servlet example 17 32
hibernate example for saving data 19 42
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

810 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