File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to open a new jsp page from servlets ?

 
Tanima Gupta
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I want to open a new jsp page after the processing done in servlets... How is this possible??
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I didn't understand. Would you please elaborate more?
 
Ryan Beckett
Ranch Hand
Posts: 192
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can forward using RequestDispatcher.forward and redirect using HttpServletResponse.sendRedirect.

Inside your Servlet:
 
Tanima Gupta
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

I hope you get it now..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tanima Gupta
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

Thankyou all for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic