• Post Reply Bookmark Topic Watch Topic
  • New Topic

calling one servlet from another servlet

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do i call one servlet from another?In one servlet named RefServlet,I am getting the username and password and updating some fields in database if the username matches with the database.Then i need to call another servlet page (AutoServlet)which is refreshing automatically containing a logout button.

Thanks
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use RequestDispatcher.forward to forward your request to the second Servlet
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.can i use response.sendRedirect() method instead of RequestDispatcher.forward
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by preethi Ayyappan:
Thank you.can i use response.sendRedirect() method instead of RequestDispatcher.forward


You can do this but the difference would be, with a response.sendRedirect (), an entirely new request, response objects gets created.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to pass the original request information like attributes and parameters to second servlet then you must use RequestDispatcher.forward ()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!