Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to navigate from jsp-to servlets-and again to another -jsp

 
Kv Payal
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
Santhosh ayiappan
Ranch Hand
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • 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.

 
Rob Spoor
Sheriff
Pie
Posts: 20497
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our servlets forum.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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

 
Punya Pratap Singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • 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.
 
Jeff Ishar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet should not be emitting any output, that's the job of the JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic