answersLogoWhite

0

The <jsp:forward ..> is actually a call to HttpServletRequest.forward(String url) which passes the request object within the server to either a servlet or to another JSP page. The new servlet or JSP page continues to process the same request and the browser is not aware of the fact that more than one servlet or page is involved. i.e., The client is not aware that the request is being forwarded somewhere else. The URL shown in the browser stays unchanged when you do this forward.

The <jsp:forward> element forwards the request object containing the client request information from one JSP file to another file. The target file can be an HTML file, another JSP file, or a servlet, as long as it is in the same application context as the forwarding JSP file. The lines in the source JSP file after the <jsp:forward> element are not processed.

The page invoked by the <jsp:forward> action has access to all the parameters in the original JSP page's request object. You can add new parameters to the request object to pass to the target page by using the <jsp:param name="..." value="..." />.

Be careful when using <jsp:forward> with unbuffered output. If the JSP file has any data in the out object, using this forward action will cause an IllegalStateException to be thrown when the page is displayed.

The response.sendRedirect() creates a new request object which doesn't carry any of old request information. The first request handler JSP page tells the browser to make a new request to the target servlet or JSP page. The URL shown in the browser therefore changes to the URL of the new page to which you redirect.

A redirect is slower than a forward because the browser has to make a new request. Another difference is that request scope objects are no longer available after a redirect because it results in a new request. If you need to pass data to the page you redirect to, you have to use a query string and pass them as request parameters or save the data in the session or application scope objects

Forward is faster than redirect but one disadvantage is that URL is not changed and also it works within the same web application. Also, when you choose to use forward, you need to think and confirm what must happen if the user reloads the page.

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is the difference between forward and backwards scheduling?

jhfgg


What is the difference between forward difference and backward difference?

Given an infinitely convergent sequence pn with limit p, the forward difference is the measure of the difference between the current term and he next. The backward difference is the measure of the difference between the current term and the previous.i.e.forward difference: &Icirc;&rdquo;pn=pn+1 - pnbackward difference: &acirc;&circ;&Dagger;pn=pn - pn-1Also, note that since they are both expressed by pn, the forward difference is recognised by the use of a delta before the pn, and the backward difference by the use of a nabla.


What is the difference between a 3 speed and a 4 speed automatic car?

difference between 3 and four speed is, a 3 speed has 3 forward gears. a 4 speed has 4 forward gears


What is the difference between 'I look forward to meeting you soon' and 'I look forward to meet you soon'?

The first is correct grammar.


Is looking forward for your positive response is right sentence?

The phrase &quot;looking forward for your positive response&quot; contains an error. The correct expression is &quot;looking forward to your positive response.&quot; The preposition &quot;to&quot; should be used instead of &quot;for&quot; in this context.


What is the difference between fourth and forth?

Fourth is like the number 4. Forth is to go forward.


What are the difference between forward engineering and reverse eng in uml?

forward engineering: the creation of code from models. reverse engineering: the creation of models from code.


What is the difference between forward lookup zone and reverse lookup zone in DNS?

Forward lookup is name-to-IP address; the reverse lookup is IP address-to-name.


is Looking forward for a positive response is a right sentence?

Yes, &quot;Looking forward to a positive response&quot; is the correct sentence. &quot;For&quot; should be changed to &quot;to&quot; to make it grammatically accurate.


What is the difference between forward slash and backward slash in c?

forward slash - division operator backward slash - special character (e.g. \n - newline) in C strings


What is the difference between power semiconductors and semiconductors?

power semiconductorspower semiconductors can drive large currents during forward biassemiconductorsemiconductors drive small currents during forward bias


What is the difference between expecting and looking forward to?

They are practically synonyms, but expecting is knowing a certain probability of an event occurring, while looking forward to is having affect toward an event occurring.