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:
request.setAttribute("variableName",object);

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

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

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

Is This Answer Correct ?    50 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the jar and war files in servlet?

778


Name the packages that work with servlet?

710


What is the difference between the http servlet and generic servlet?

824


What do you mean by cgi in servlet?

791


Why is init() method is used in servlets?

710






Elucidate servlet attributes and its scope?

736


When to use doget() and when dopost()?

800


How do we translate jsp?

753


Can you use javascript in servlets?

774


Can a jsp be called using a servlet?

745


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

787


what do you understand by url rewriting?

686


What is the requirement of servlet config and servlet context implemented and how are they implemented?

719


Explain the concept of ssi ?

774


What are the types of protocols supported by httpservlet ?

895