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

Answer Posted / kuru

for example if you want to pass your name from one servlet
to another,

in fiest servlet file....

String name = "Tom"
request.setAttribute("name",name);

RequestDispatcher dis = request.getRequestDispatcher
("Servlet2");

request.Forward(request,response);



in second servlet file....

request.getAttribute("name");
//this line will display "Tom"

Is This Answer Correct ?    46 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the jobs performed by servlets?

669


What is a servlet context object?

710


When servlet is loaded?

675


What exactly is a servlet?

615


What do you mean by session tracking and also explain its techniques?

579






What is meant by a web application

627


When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?

652


What are the difference between RMI and Servlets?

1135


What do you mean by mime type?

638


Explain web application directory arrangement?

674


Differentiate between the web server and application server?

654


What are the advantages of cookies?

710


What are the phases of a servlet life cycle?

707


Explain the war file?

686


What is the workflow of a servlet?

795