I really can't understand why my servlet isn't working. It is compiling fine and I have used println to make sure that the program is running where it should, but no page is being sent to the client. I have tried to use response.sendRedirect("options.jsp") as well as the following:
So when I get the password right, then the system prints out "In equals" and "After RequestDispatcher", but no new is displayed by the browser.
Joe Lemmer wrote: where you can see the actual folder icon for WEB-INF.
As stated above more info would help. Consider the following: type the correct URL of one of your JSP's in the browser... Is the JSP at the root? If so, prefix your resource string with a "/" e.g. - getRequestDispatcher("/options.jsp");
If that solved your issue, its safe to conjecture your use of a relative path may have been the problem. If not, provide more info...
Thanks for your reply. I have tried using "/options.jsp" and also using the full "http://localhost:8080/MiniProject/options.jsp", which takes me to the right page when I type it into a browser.
I don't know what other information I can provide really. All of my debugging statements are printing out fine, both before and after the RequestDispatcher code, as I said above the address is fine, there are no errors in the log, the html source code is completely unchanged from the start page, the web.xml is fine. Does anybody have any other ideas? This should be simple, I've done it a few times before and it's worked fine.
I've gone through the MVC tutorial again in chapter 3 of HF Servlets & JSP and it worked fine. I also shortened the code so that all there was in the servlet was the RequestDispatcher code ie:
and this returned the result.jsp page fine.
I then commented out all the code in the doPost method of the servlet that won't return a page, except for:
and it still does not return the options.jsp, but it does print the After RequestDispatcher message. I'm sure it's something very basic that I'm doing wrong, but with no actual error messages anywhere, I've no idea what.
I have made the request.getRequestDispatcher() method work by calling the servlet direct from the following code:
So the problem must be the way I am calling the servlet, or something from the client side. What I originally had for my client side code was:
I think that the sendLogin() function is the critical thing, but I can't see any reason as to why there would be any difference to this than the simpler html that I mentioned in this post. Is it something to do with the jQuery '$.post()' method? It works fine in the sendSignup() method and as I've written before, all the params etc are getting through and the servlet is running right through to the end, so I don't see why it would make any difference how the doPost() method of my Servlet (which has the request.getDispatcher() code in) was called. It should result in the same result...except it doesn't.
Did you ever solve this problem? I am having the exact same problem.
I've traced my code with output statements in both my servlet and my jsp, and my forward is actually hitting and processing my entire JSP page, but then goes off to somwhere else and the end result is a valid, but empty, html page.