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

How do you invoke a servelt?

620


What do you mean by interservlet communication?

580


Explain the jar and war files in servlet?

553


Difference between get and post in java servlets?

540


Difference between doget and dopost?

679






Describe in brief RequestDespatcher?

594


What is servlet in web technology?

575


Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?

614


Explain get and post.

649


What is ServletConfig object?

606


Why session tracking is needed?

582


What is difference between get and post method?

572


How does tomcat servlet container work?

592


What is the need of servlet filters?

538


Is tomcat a servlet container?

573