Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2005-03-07
2
Medium Priority
?
4,473 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
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

580 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