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

Answer Posted / vinod muda

In First Servlet i.e Test

String name = "Vinod";
request.setAttribute("name",name);
RequestDispatcher dis = request.getRequestDispatcher
("Test2");
dis.forward(request, response);
---------------------------------------
Now in Second Servlet i.e Test2

String name = (String) request.getAttribute("name");

Is This Answer Correct ?    29 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Describe some assignments that are executed by servlet container?

579


What is the functionality of actionservlet and requestprocessor?

592


What do you mean by interservlet communication?

580


What do you mean by annotations in servlet?

580


What is war file?

578






Can filter be used as request or response?

540


What are all the protocols supported by httpservlet?

646


What is the use of httpservletresponsewrapper?

528


Can we use the constructor, instead of init(), to initialize servlet?

580


Is it good idea to create servlet constructor?

738


How can a servlet be used to generate plain text instead of html?

543


What is the capacity the doget can send to the server?

568


What must be implemented by all servlets?

574


How do you invoke a Servlet? What is the difference between doPost method and doGet method?

644


What are all the advantages of servlet over cgi?

603