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

Why don't we write a constructor in a servlet?

586


Write a program to show the functionality of servlets.

553


What is the inter-servlet communication?

698


What is url encoding and url decoding

582


What is the difference between Difference between doGet() and doPost()?

754






Which application server is best for java?

556


What are the features added in Servlet 2.5?

765


What is Servlets and explain the advantages of Servlet life cycle?

579


Explain jsessionid?

617


What are different ways for authentication of servlet?

525


What is the difference between jsp and servlet life cycle?

684


What are the different methods of session management in servlets?

532


What is generic servlet class?

596


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

543


Which java application server is the best?

545