doPost throws Exception "Size not matching"

  • Follow


Dear all,

while i am trying to submit form to servlet , though things are doing
pretty good ,but mysteriosuly ,as soon as the servlet gets the post
request it throws an exception ,which when is printed (Exception
e.getMessage()) states "Size not matching" . Following are the related
code lines :

 public void doPost(HttpServletRequest req, HttpServletResponse res)
throws
      ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    try {
     System.out.println("start dopost");
     //
    //          remaining code
    //
    } //try ends here

   catch(Exception e)
   {
        System.out.println("Exception message is " +  e.getMessage() );
   }

Hence the System.out.println() statements come in the order  like :

1: Exception message is Size not matching       //printed in catch
block
2: start dopost                                                 //
first line in the try block

Any help on this issue will be highly appreciated ....

Regards,
Madni

0
Reply omermadni (22) 4/24/2006 10:07:17 AM

Madni a =E9crit :

> Dear all,
>
> while i am trying to submit form to servlet , though things are doing
> pretty good ,but mysteriosuly ,as soon as the servlet gets the post
> request it throws an exception ,which when is printed (Exception
> e.getMessage()) states "Size not matching" . Following are the related
> code lines :
>
>  public void doPost(HttpServletRequest req, HttpServletResponse res)
> throws
>       ServletException, IOException {
>
>     res.setContentType("text/html");
>     PrintWriter out =3D res.getWriter();
>
>     try {
>      System.out.println("start dopost");
>      //
>     //          remaining code
>     //
>     } //try ends here
>
>    catch(Exception e)
>    {
>         System.out.println("Exception message is " +  e.getMessage() );
>    }
>
> Hence the System.out.println() statements come in the order  like :
>
> 1: Exception message is Size not matching       //printed in catch
> block
> 2: start dopost                                                 //
> first line in the try block
>
> Any help on this issue will be highly appreciated ....
>
> Regards,
> Madni

First thing, just leave the execption bubbling up to the servlet engine
while you are in test phase, this will give you three major things :
a) The location of the error
b) The kind of exception
c) At compilation time, any unhandled exception kind that you should
wrap into a ServletException then throw. THe sample code can be :

doPost(.......) {
    try {
       // Business code
    } catch (Exception e) {
       if (e instanceof ServletException || e instanceof IOException)
           throw e;
       throw new ServletException(e);
    }
}

Best regards

Philippe

0
Reply philippe.malka (11) 4/24/2006 2:01:24 PM


1 Replies
35 Views

(page loaded in 0.038 seconds)


Reply: