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
What is lazy loading and what is Generic Servlet Class?
How we can get ip address of client in servlet?
Why do we need a constructor in a servlet if we use the init method?
Is servlet a controller?
What are the kinds of http requests?
what is the different between a servlet and a cgi? Why do you go for servlet rather than cgi?
What is the capacity the doget can send to the server?
What is meant by Servlet? What are the parameters of service method?
Why do you use session tracking in httpservlet?
Why doesn’t a servlet include main()?
Can filter be used as request or response?
When a client request is sent to the servlet container, how does the container choose which servlet to invoke?
What is the difference between the servlets and cgi programs?
What if we pass negative value in load-on-startup?
How to notify an object in session when session is invalidated or timed-out?