In servlets, what is the use of sendredirect(),include( ), forward() ?and in applecation level at what scnario they will be used

I know only that send redircet is of client side. and remaing are severside functions

Showing Answers 1 - 3 of 3 Answers

When you invoke a forward request, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request. This process occurs completly with in the web container. When a sendRedirtect method is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completly new request any object that are stored as request attributes before the redirect occurs will be lost. This extra round trip a redirect is slower than forward.

The include action, on the other hand, executes for each client request of the JSP, which means the file is not parsed but included in place. This provides the capability to dynamically change not only the content that you want to include, but also the output of that content. The syntax for the include action is <jsp:include page="some-filename" flush="true" />. Note that the flush attribute must always be included (in JSP 1.1) to force a flush of the buffer in the output stream

surae

  • Nov 4th, 2005
 

sendredirect() is used to redirect the request to the webpage present in some other server.forward() is used to redirect the request to the webpage present in the same server.include() is used to include the request to the webpage present in the same server.

  Was this answer useful?  Yes

ss

  • Nov 10th, 2005
 

sendredirect() is a method to send a file to user when perticular condition is true.

include() and forward() methods are using in requestDispatcher() in this case.

reqdis.include()  takes the input from the page in which this method is invoked. where as reqdis.forward() acts like a sendRedirect() method these two will not take any input from the page. these are to send directly a page(like login) to user.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions