• 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 navigate from jsp-to servlets-and again to another -jsp

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am writing a simple Web application using only jsp and servlets. I have a form in a jsp page which is calling a servlet in form action. If it is till this, it is working fine and I could see the text printed in the servlet. However, if I am using RequestDispatcher to navigate again to another jsp page from servlets, it is only showing the jsp page contents and not showing the text printed thru servlet program.

What should I do so that it waits on servlet's output page for some time and then navigates to jsp page?
I tried Thread.sleep but that is not working.

Please help.

Thanks
 
Ranch Hand
Posts: 81
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"it is only showing the jsp page contents and not showing the text printed thru servlet program. " . Do you mean you are not able to retrive the values in the JSP file after forwarding from the servlet ?.

If you want to set some value from the servlet and pass it on the JSP page, you can use the request object.

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our servlets forum.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you are using PrintWrier object (out) as out.println("") to print some text on JSP and also using RequestDispatcher object to forward the request to JSP. If this is the case then your out.println("") code will not work.

~ abhay

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not printing any response.I am just creating a xml file.which is being created but not containing the desired result as I mentioned above in issue.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please either put the code here or clear precise steps you are trying to achieve your goal with ? Your objective is unclear.

Cheers
 
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
Your servlet should not be emitting any output, that's the job of the JSP.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic