Hi, im kind of new to servlets. i have a servlet which accepts data from a HTML form. Basically 2 numbers, according to the option chosen, their addition,multiply etc. User enters the answer, servlet checks whether it was correct or not. If wrong, shows solution. processRequest() is the function which is called by doPost. It calls processAnswer() which basically does the forwarding of the page according to the answer. Heres processRequest
WHICH CALLS processAnswer()
Really need help here..I tried adding a "return" in processRequest, didnt help.
I am sorry, did not get your problem.. If "Cannot forward after response has been committed" is the problem then always remember that you can not forward the servlet/jsp to another one of a kind after you have committed the response to the client!! Remember that always, forward before you commit.
why you put after catch ?...i guess first it enters catch and forward to some page agin it calls processAnswer and init once agin you are trying to forward .... instead you put your processAnswer(answer, opt, number1, number2, request, response); inside try block
hi, Do remember that in switch case once a condition is met in a case all the subsequent case blocks get executed ,hence the error .To make it work find an alternative to switch case approach.Try using if ...else I think it might work out [ December 06, 2008: Message edited by: Abhijit Rai ]
Joined: Dec 05, 2008
Ok, sry for the delay.. Managed to solve the problem after a lot of searching... Had to write a 'return' after the forward command.. About the switch case executing every statement, doesnt writing a "break" solve that?..Just asking..
Yes of course. You know the fundamentals of switch case statement..... By writing break you tell the program to come out after the case has matched.... Otherwise once a case is matched and break is not used then all the subsequent cases too are evaluated.... Hope this helps.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Cannot forward after response has been committed