?
Solved

Unreported Exception : must be caught or declared to be thrown error at servlet

Posted on 2005-03-07
2
Medium Priority
?
4,431 Views
Last Modified: 2013-11-24
hello all,

firstly i don't know wheter i'm in a right place to ask a question about the servlet...:D
my problem is..i have a servlet file names myServlet.java which is calling a method from myJavaProvisioning.java. when i compile this both file, i've got an error says "Unreported Exception : ....must be caught or declared to be thrown" in my servlet. perhaps anybody could help me to solve this problem..


script at myServlet.java

  public void handleAction(HttpServletRequest request,
                           HttpServletResponse response) throws
      ServletException, IOException {
 
    String result = null;
    boolean status = false;
    myJavaProvisioning subscriber = new myJavaProvisioning();

     if (doaction.equals("createCFAll")) {
      status = subscriber.createIPCentrexFeature(userId,forwardTo);
     }

     if (status) {
      result = "success";
     }
     else {
      result = "failure";
     }

}

and script at myJavaProvisioning.java something like this

  public boolean createIPCentrexFeature(String userId, String forwardTo) throws
      ObjectAlreadyExistException, InvalidParameterException,
      ObjectNotFoundException, SystemException, Exception {

    boolean status = false;
   
    try {

        TestUserManager userManager = new TestUserManager();
        myUser ipcfManager= userManager.getUser(userId);

        CallForwardAll cfAll = ipcfManager.createCallForwardAll(forwardTo);
        status = true;
 
    }
    catch (ObjectAlreadyExistException ex) {
      logger.error("Unable to " + doaction + " : " + ex.getMessage());
      if (this.isDebug()) {
        ex.printStackTrace();
      }
    }
    catch (InvalidParameterException ex) {
      logger.error("Unable to " + doaction + " : " + ex.getMessage());
      if (this.isDebug()) {
        ex.printStackTrace();
      }
    }
    catch (ObjectNotFoundException ex) {
      logger.error("Unable to " + doaction + " : " + ex.getMessage());
      if (this.isDebug()) {
        ex.printStackTrace();
      }
    }
    catch (SystemException ex) {
      logger.error("Unable to " + doaction + " : " + ex.getMessage());
      if (this.isDebug()) {
        ex.printStackTrace();
      }
    }
    catch (Exception ex) {
      logger.error("Unable to " + doaction + " : " + ex.getMessage());
      if (this.isDebug()) {
        ex.printStackTrace();
      }
    }
    return status;
  }


a really appreacite for any help input..
0
Comment
Question by:eg4
[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
2 Comments
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 13483002
u need to handle the possible exception returned by createIPCentrexFeature(), or declare that your method may throw it

u could use something like the following to handle it:

tr
{
    status = subscriber.createIPCentrexFeature(userId,forwardTo);
}
catch (Exception ex)
{
   throw new ServletException("error calling createIPCentrexFeature");
}
0
 

Author Comment

by:eg4
ID: 13483875
thanx and it works!!
0

Featured Post

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

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…
A solution for Fortify Path Manipulation.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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