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

Answer Posted / debojit

First of all u have to set the value by setAttribute()
method such as:
getServletContext().setAttribute("variableName",object);

Then u have to forward that request to other servlet by
using that procedure,


RequestDispatcher rd=getServletContext
().getRequestDispatcher("/servlet");
rd.forward(request,response);

U can get that information from that servlet by using the
method::
getServletContext().getAttribute("variableName");

Is This Answer Correct ?    23 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do we translate jsp?

664


What is the use of send redirect () method?

665


What is context in servlet?

644


What is the GenericServlet class?

711


What is the workflow of a servlet?

795






Why is init() method is used in servlets?

617


What is a server side include (ssi)

643


Explain jsessionid and when is it created?

679


How do cookies work in servlets?

679


What are the different ways we can maintain state between requests?

665


What is the difference between using getSession(true) and getSession(false) methods?

647


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

651


When a servlet accepts a call from a client, it receives two objects. What are they?

859


What are the servlet events?

685


What is the use of servlet context?

618