You aren't opening a JSP page, you are forwarding or redirecting to a JSP page.
Check Servlet API for forwarding and redirecting.
Tanima Gupta
Greenhorn
Joined: Mar 18, 2011
Posts: 12
posted
0
thanks for the reply....i tried both forwarding and redirecting.. but instead of navigating to other page it sends the code of the new jsp in the form of response to index.jsp instead..
John Todd wrote:Sorry, I didn't understand. Would you please elaborate more?
ohk i have made a jsp page where i am using both jsp and ajax.. in ajax you use xmlhttp.responseText to get the response from the server(through servlet)..
In servlets, verification is done properly...after the verification i want to navigate the user to his profile i.e. a new jsp page .....for that i am using both RequestDispatcher as well as sendRedirect..
In sendRedirect, response is first sent to client and then to the server for accessing another page..which i dont want..
In RequestDispatcher its happening the same as well.....the entire code of the new jsp sent in the form of response to client in xmlhttp.responseText....
it does not forward to another jsp from servlet...
Bear Bibeault wrote:If you want to move to a new page, don't use Ajax. The whole purpose of Ajax is to make a request without doing a page reload.
Yes probably this was my mistake. The Ajax call was making the response come back to the client. I removed Ajax code and doing with simple jsp and servlets and its working fine..