• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to open a new jsp page from servlets ?

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

Inside your Servlet:
 
Tanima Gupta
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic