This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I'm attempting to process a request and send it to the appropriate JSP file using the folowing syntax:
But I get a non-HTTP request or response Exception as soon as I hit the forwarding line. I checked the method and it is POST. However if I change the forward to include action it works. I've read the API doc for the forward and the include but can't tell where and when to use what. Any and every thoughts are appreciated
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
posted
0
Med The _jspService method requires an HttpRequest object, is that what you are sending it? It looks like you're using two different request objects in your code: one when you get the dispatcher: RequestDispatcher dispatcher = request.getRequestDispatcher And then another when you forward the request to the jsp. ("/PersonalData.jsp");dispatcher.forward(req, res); Make sure the req variable is referencing an HttpRequest object. The same goes for the response object you are passing it. hope that helps [ April 04, 2002: Message edited by: Dave Vick ]
Dave
Med Shabe
Ranch Hand
Joined: May 08, 2001
Posts: 84
posted
0
Sorry for misleading you Dave, There's a typo there. The request object is the same. So the problem still stands. RequestDispatcher dispatcher = request.getRequestDispatcher ("/PersonalData.jsp");dispatcher.forward(request, response);
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
posted
0
Med Can you post some more of your code and the exact error message and stacktrace your getting. That'll hel in figuring out what the problem might be.
Med Shabe
Ranch Hand
Joined: May 08, 2001
Posts: 84
posted
0
Thanks for looking into this Dave. Below I have provided code anippet along with debug info. I'm just checking for the value of radio buttons:
Med The only method in the code you posted that can generate a ServletException is the forward method. forward method only generates one if the resourse it is forwarding to throws one so the actual Exception is coming from the JSP your forwarding to. From what the error message says I would double check to make sure the request and response objects you're forwarding are HttpRequest and HttpResponse objects. Is the servlet an HttpServlet? And are the req and resp varialbe the same ones you are passed in the doPost method? If all of that is ok then post the entire doPost method and that should help. Also, and don't take offense, did you modify the _jspService method in any way?
Med Shabe
Ranch Hand
Joined: May 08, 2001
Posts: 84
posted
0
I have not modified the _jspService no. based on your previous comment I think I know what I'm doing wrong now, but not sure how to get around it. I'm starting out with html and then try to go to a jsp page from the servlet. I've attached the doPost as you suggested. Perhaps I need to start up with a jsp instead. In that case do I need to pass the erquest, response objects to the servlet in order to utilize the forward action? If so, how? Thanks.