doPost throws Exception "Size not matching"

M

Madni

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
 
P

PMA

Madni a écrit :
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top