What is difference between Forward() and sendRedirect()
methode?

Answer Posted / venkat

forward() method send source prg to target web resource prg
in same web application.and use source and target web
resource prg are use same req,res objects so will use data
in target web resource prg.

rd.forward(req,res)

sendRedirect() method send source web resource prg to target
web resource prg in same webapplication or two different web
applications in same server or different servers.and this
method will not use same req,res objects so if you want to
send data source to target web resource prg use query
string.

r.sendRedirect("srv2"?a=10);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of send redirect () method?

586


How will two or three servlets interact or communicate with each other?

898


Why do we have servlet filters?

595


How do we share data using 'getservletcontext ()?

541


What is the difference between jsp and servlet life cycle?

685






What is the difference between the getrequestdispatcher(string path) method of javax.servlet.servletrequest interface and javax.servlet.servletcontext interface?

563


What is difference between the HTTP Servlet and Generic Servlet? Explain about their methods and parameters?

613


What are the difference between RMI and Servlets?

1049


What is http servlet? Explain with the help of an example.

578


Which protocol will be used by browser and servlet to communicate

580


What are the types of protocols supported by httpservlet ?

704


How are filters?

580


What do you mean by url pattern in servlet?

624


How do I support both get and post from the same servlet?

696


How to rectify errors in java servlet while compilation?

517