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 to get the path of servlet in the server?

531


What do you mean by cgi in servlet?

627


When servlet object is created?

600


Which HTTP method is non-idempotent?

616


Why do we need a constructor in a servlet if we use the init method?

515






Why do we have servlet listeners?

597


What is ServletContext object?

641


What is servlet configuration?

523


What’s the difference between sendredirect and forward methods

564


how the HTML data stored in web server?

1952


What is servlet and its advantages?

519


Difference between httpservlet and generic servlets?

602


How can we perform any action at the time of deploying the project?

619


How can we refresh automatically when new data has entered the database?

617


What are the differences between servlet context vs servlet config?

575