• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

JSP- Servlet communication

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know how could the following be done
If i have a jsp page and want to transfer control to a servlet1 perform some processing there and then transfer control to servlet2 perfrom some computations there then take the data from servlet2 and servlet1 and transfer it to the jsp page.Could some one help me please
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the <servlet> tag in web.xml, declare both servlet1 and servlet2. Using the <servlet-mapping> tag in web.xml, give each servlet it's own URL. Have the starting JSP/HTML contain servlet1's URL as it's action. Once processing in servlet1 is done, get a RequestDispatcher using the URL for servlet2 and forward. Once servlet2 is done it's work, get a RequestDispatcher using the URL of the servlet you want to display as the final JSP.
Think of each JSP getting it's own implicit <servlet> and <servlet-url> tag. The RequestDispatcher allows you to send a request to any resource, declared explicitly or implicitly.
 
shawn kennedy
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i pass the data got from servlet2 back to servlet1 and then data from servlet1 and servlet2 back to jsp in a request dispatcher am i suppose to use request.setattributes()method to do tht
 
reply
    Bookmark Topic Watch Topic
  • New Topic