How do you pass the data from one servlet to another
servlet?

Answer Posted / harish

Using Request Dispatcher, you can send the values and
forward to another page.
ServletContext.getRequestDispatcher();
reqDispatcher.forward(req,res)
Forwards a request from a servlet to another resource
(servlet, JSP file, or HTML file) on the server.
reqDispatcher.include(req,res)
Includes the content of a resource (servlet, JSP page, HTML
file) in the response.

Is This Answer Correct ?    80 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many objects of a servlet is created?

990


Why is Servlet so popular?

774


How servlets are deployed in java?

713


Given the request path below, which are context path, servlet path and path info?

750


Can servlet have a constructor ?

789


Tell us something about servletcontext interface.

813


How forward () method is different from send redirect () method?

704


Differentiate between the print writer and servlet output stream?

738


What is the GenericServlet class?

846


What is api in servlet?

741


What is the difference between encodeRedirectUrl and encodeURL?

821


Explain url encoding in servlet?

783


How would you create deadlock on your servlet?

820


What do you mean by httpservlet and how it is different from the genericservlet?

732


Is servlet a controller?

737