Difference between forward and sendRedirect


Control can be forward to resources available within the server from where the call is made. This transfer of control is done by the container internally and browser / client is not involved. This is the major difference between forward and sendRedirect. When the forward is done, the original request and response objects are transfered along with additional parameters if needed.


Control can be redirect to resources to different servers or domains. This transfer of control task is delegated to the browser by the container. That is, the redirect sends a header back to the browser / client. This header contains the resource url to be redirected by the browser. Then the browser initiates a new request to the given url. Since it is a new request, the old request and response object is lost.

For example, sendRedirect can transfer control from http://javapapers.com to http://anydomain.com but forward cannot do this.

‘session’ is not lost in both forward and redirect.

To feel the difference between forward and sendRedirect visually see the address bar of your browser,
in forward, you will not see the forwarded address (since the browser is not involved)
in redirect, you can see the redirected address.

When can we use forward and when can we use sendRedirect?

Technical scenario: redirect should be used

  1. If you need to transfer control to different domain
  2. To achieve separation of task.

For example, database update and data display can be separated by redirect. Do the PaymentProcess and then redirect to displayPaymentInfo. If the client refreshes the browser only the displayPaymentInfo will be done again and PyamenProcess will not be repeated. But if you use forward in this scenario, both PaymentProcess and displayPaymentInfo will be re-executed sequentially, which may result in incosistent data.

For other than the above two scenarios, forward is efficient to use since it is faster than sendRedirect.

Ads by Google

Example for forward and sendRedirect based on real world

Consider the real world scenario, the milk man comes and asks for monthly payment to you in your house. Here house is the container and you are a resource existing in the container. Milk man is the client or browser.

He asks for the monthly payment to you, this is the request made by the browser to resource A. If you go inside your house and ask your mother (another resource B inside the same container) for the cash and come back and deliver to milkman this is called forward.

If you ask the milkman to speak himself to your mother inside your house or you ask the milkman to speak to your father who is in his office (different domain) then this is called redirect.

This JSP tutorial was added on 13/05/2008.



444 Responses to “Difference between forward and sendRedirect”

  1. Sarma says:


    Thank you for your excellent work. I liked the example you have given here for the difference between forward and redirect.

  2. Aatish says:

    Brilliant example! :)

  3. Tan Ho says:

    Very good explanations for forward and execellent example for the difference

    Thank you!

  4. chandana says:

    Ha ha ha thats a gr8 example….

  5. Ramkrishna says:

    really good explanation for difference between forward and redirect and practical example.

  6. mtl says:

    Very good! Thanks a lot.

  7. dipak sonawane says:

    awesome style to explain this scenario,
    I was really searching on internet for the real example for sendRedirect and forward. Finally I found from this article … thanks a ton

  8. Priyanka says:

    Finally, I know the difference between forward and sendRedirect :P . Thanks a lot.

  9. sarayu says:

    Nice Explanation. Thank You

  10. Anonymous says:

    Good points detailing out the differences and mentioning when to use what. Thank you.

  11. SAILESH says:


    Forward and redirect difference example is good .

    I have read this blog and this is really very good to read as in the example understood.

    I think if every topics related to java or advance java will be written like this with example then it is easy for everybody to understand.


  12. Prasanth says:

    In the technical scenario given above – for payment & display of result, why do we need client interaction? Correct me if I am wrong.
    for example, the user does a payment by clicking Pay Now button. In most of the online payment sites, there will be a warning saying – do not press fresh button or back till you get a confirmation message – I think in this scenario, forward is happening. Please let me know whether my understanding is correct? ( email pn8572@gmail.com)


    • Gopal Rao says:

      Prashant,In the scenario of the online payment when the sites give a warning saying “Please do not press the back or the refresh button” they are using redirect not the forward.Because once the payment is successful then again its getting redirected to a different page which is showing the payment successful information.

    • Swaraj says:

      Hi Prasanth,

      In the payment and Displayinfo once fill informaion on merchent page(info)related once we presss the submit button then internaly it will goto payment site if u want conformation see URL(exp: flipcart==> to anybanksite) then in this time it will show dont press refresh button or back bcz if u prsss payment is not completed so transaction is not completed so transaction is rollback bcz of that it will show error page. once payment is sucesses then it redirect to merchentsite.now if u press refress button it wil show only displayinfo will refreshed but it wil not called payment.

  13. ali says:

    It is an excellent and crisp definition.thanks for such a explanation.

  14. Jagdish Adhikari says:

    Really very logical real time explanation of forward & sendRedirect , great work

  15. Biswabrata Banerjee says:

    This site is the best among many !!
    Great !

  16. srinivas says:

    Simply superb. Nice Explanation with real world example for forward and sendredirect

  17. Vamshidhar says:

    Fabulous!!!! Really great thinking in real world against the technologies.

  18. Supri says:


    Really too good.In many websites they just give the definition.And only in this blog i got it cleared.Thanks.

  19. srinivas says:

    difference between forward and redirect is now crystal clear.
    vvvvvvvvvvvvv good explanation with genaral example.

  20. Praveen Kumar Jayaram says:

    You rock Joe! That was really helpful :)

  21. aryan says:

    Awesome example…. keep up the good work!

  22. Joe says:

    thanks guys.

  23. Srikanth S says:

    Excellent Joe….Real world example is too good..

  24. nagarjuna says:

    Finally, I know the difference between forward and sendRedirect :P . Thanks a lot.

  25. Saravanan says:

    Excellent example for forward and redirect. Great Work and Great thought…Keep the good work…

  26. Saubhik Aon says:

    Excellent work!!! really it will help lots of people who are trying to understand forward and sendRedirect….really great job….even the last example is awesome.

  27. shyama says:

    Very good discription ;

  28. Bhanumat says:

    Excellent Joe. Real world example is very clear.
    Thank you for your work.

  29. Murali says:

    I liked the milk man example..vry short and 100% clear…

  30. Bala says:

    Wow This is very helpful to understand the core concept of forward and sendRedirect. The examples above gave very clear understanding of the concepts. Keep posting lots of topics.

  31. naba says:

    nice example…. thank you for your excellent work…

  32. Pragati says:

    Thanks I liked your Example.

  33. preity says:

    Thanks…Nice explanation

  34. Chirtrarasan says:

    Thanks…… and I can understand your explanation easily

  35. arvind says:

    I find this site to be unlike from the others. I would like to appreciate your work & passion…simply superb!!!

  36. vinay s salunke says:

    HI Joe,

    I really liked the example and enjoyed learnng the concept.

  37. Rajaram says:

    Haha.. Very Funny Example and very indepth explaination

  38. Palmeet says:

    Excellent Real world example is too good..
    i mean it understands very easily……….
    thanks buddy…

  39. Uttam says:

    Very good example of difference. nice..

  40. veeraswamy says:

    this is very nice explanation example of forwad and senddirect.is there any other type of examples are there.pls forward to my mail.thanks

  41. parvathy says:

    Very nice article, Could you please include spring and hibernate in this site.

  42. Siva says:

    Very good explanation. As somebody suggests plz. update springs and hibernate in this blog.

    Thanx again

  43. Shaye says:

    Thanx a lot.. This info really helped!!

  44. anbu says:

    HI Joseph,
    Excellent work!
    thank you!
    Could you please include spring,struts and hibernate in this site with real world examples!

  45. venkat says:

    this is very usefull for me.

  46. Anonymous says:

    excellent example…

  47. Mukesh says:

    this is it!!!!!!!!!!!!!!!!!!!! what many looking for as well as i.

  48. Magesh says:

    thanx… a lot

  49. Ashok says:

    Thanks a lot for explaining the difference between forward and redirect in simple way..

  50. Rangappa says:

    Its very nice to uderstand with examples…
    its very nice if u explation other topic (j2ee and advance topics)….
    very very nice….

  51. Priya J says:

    I could understand your example very well. But there is a confusion with a real time situation that I’m thinking about.

    If you go to irctc.co.in for payment it will redirect you to netbanking application. At that time since this is a redirect it’s a new request and the old req/resp will be lost. But once payment is done it is going back to the irctc.co.in. Where this url is preserved? in the session?

    It would be very helpful if you clarify the situation mentioned above.

    • Niraj says:

      There is an attribute of HTTP Header called referer (actual spelling referrer) which will always keep track of the last URL from where the request is being made.

  52. Amutha says:

    Thanks Joseph

  53. Anonymous says:

    Nice Example with good explanation

  54. Anonymous says:

    Very good explanation…………..

  55. C.P.Singh says:

    Thanks for good explaination with good examle

  56. bsr says:

    gd explanation….besides i demond code examples….

  57. Anonymous says:

    Simply awesome !!

  58. Sekahr says:

    Hi boss.
    I got a good explanation after a long time.

  59. Raju says:

    Very nice explanation…

  60. nani says:

    very nice example,it helps me a lot

  61. shashi says:


    Thank you for your excellent work.

  62. Sunil says:

    Super job!! the examples are very clear to understand the concepts

  63. Manoj says:

    really nice …explanation and example

  64. Aarya says:

    rocks !!!

  65. krishan says:

    brilliant presense of mind

  66. abhishek says:

    nice explanation, thank u very much..

  67. Jyotshna says:

    its really awsm….

  68. Udhay says:

    i never seen such a simple example like this for forward and redirect… thanks a lot

  69. Kishore says:

    Good Explaination.

  70. kuzma says:

    nice work!

  71. sureshsp says:

    Excellent you have given such nice explanation.The way your writing and explaining every thing perfect

  72. Kinjan Ajudiya says:

    nice explanation but if you can give example of forward then it is good …thanks

  73. elangovan says:

    I could understand your example very well. But there is a confusion with a real time situation that I’m thinking about.

    If you go to irctc.co.in for payment it will redirect you to netbanking application. At that time since this is a redirect it’s a new request and the old req/resp will be lost. But once payment is done it is going back to the irctc.co.in. Where this url is preserved? in the session?

    It would be very helpful if you clarify the situation mentioned above.

  74. Joe says:

    Thats a very nice question relating to the context.

    Here this is a redirect and there is no doubt about it. irctc (web application) is integrated with the payment gateway. While integrating, there will be provision to set the callback url and the list of arguments that needs to be passed back to the web application. So, once the payment is done, the payment gateway will call the registered url (in this case irctc). So there is no need to preserve the url in session. The call will be done by payment gateway.

    Some additional information:

    Internally there will be another url involved called notify url. On payment, this notify url (in the irctc web application) will be called along with status variables. This will happen in a notify-acknowledgement mode. Using the status variables, webapplication (irctc) can update its database or execute process like sending an email (ticket) to the user.

  75. Reji says:

    Great example !!! Nice work…

  76. nikita says:

    nice work…n a very gud example to explain the difference.

  77. Dhanunjay says:

    Nice way of explaining the difference b/w forward and redirect…

  78. sridhar says:

    awesome example, which makes crystal clear between forward and Redirect.

  79. Nitin says:

    can anybody tell me where the request and response objects will go in both the cases

    what i think about
    that in this case previous req n res will be destroyed when control is transferred to another page

    req n res will transferred to another page along with the control

    n pls tell me about the include also.. i think in this case previous req n res comes back to the same page after transferring the control

    please correct me if am wrong….

  80. balu says:

    nice example

  81. Priya says:

    the examples are very clear

  82. malli says:

    good solution

  83. C.P.Singh says:

    Thanks to share the good explanation with real example

  84. swathi says:

    Hi Joseph,

    When i click redirect in jsp it will go to struts and will call funtion redirect i..,
    public void redirect() throws IOException, ServletException
    HttpServletResponse res = null;


    here i want to redirect(i want to change the url in address bar using sendredirect) but it is throwing nullpointer exception)
    how can i get from this.
    pls help me……..

  85. eshwar says:

    kalakara kolandha

  86. eshwar says:

    Its really helpful for me to study thank you dude

  87. Deepak says:

    theory was good thank u for that and could u please post some example programs :)

  88. swathi chintala says:

    very very nice example.wonderful xplanation.

  89. Rama says:

    Nicely explained… Good Job

  90. krishna says:

    Once if we have this type of real time explanations, at that time we can’t forget the concept. . .
    Anyhow superb explanation. . .

  91. Om says:

    Very good example. Thanks

  92. radhakrishna says:

    Thank you a lot. This is really very useful. keep blogging.
    Thanks again…:)

  93. Badari says:

    Excellent Example

  94. anonymous says:

    very very good and clear difference b/w both of them and with a good example

    Thanks very much…for sharing these things….!!!!

  95. Nandhini says:

    Good example……..

  96. Anonymous says:

    excellent example gr8!!

  97. GK Than says:


    Example is super, is it helps lot to remember the concept……

    Great again

  98. Anonymous says:

    It a Good Example for ever

  99. Anonymous says:


    It is Very Good Example and we can Remember easily.

  100. Anonymous says:

    What a funny example!

  101. Saoni De says:

    Thank u very much for giving such an exellent example

  102. rajesh says:

    nice realworld example………

  103. Naveen Sharma says:

    Hi Joseph,
    I appreciate your initiative for the beginners help,Your blog is very much helpful for me to remove confusion about this topic . you right great example of payment process . It is very much practical example i have found .

    Thanx allot.

  104. shakti prasad rath says:

    This is really a good solution. Thanks for this solution

  105. Anonymous says:

    Hi thanks a lot. This is really good

  106. satyendra says:

    aaj antar samjh aa gaya forward or redirect mein …………. wonderfull example

  107. vivek says:

    gud work:-)))

  108. kondaveeti somasekhar chowdary says:

    superb explanation. . .

  109. Sandhya says:

    nice Example :)

  110. Partha says:

    Great man….nice and very very helpful example.

  111. Anonymous says:

    nice explanation(example is very good easy understandable)

  112. Anonymous says:

    perfect example.. too good

  113. pramiya says:

    nice work!!!!!!!!

  114. Rajkumar.G says:

    Nice example.

  115. shilpa says:


  116. samina says:

    very well example!

  117. chaitu says:

    good explanation ,

  118. Anup says:


    Thanks Joe.

    I have gone through most to the link to get my answer ‘to the point’ but i never got my answer up to satisfactory label.
    In this link i got my answer ‘to the point’ with wonderful example.
    Thank you Joe once again. Please continue as long as possible.

    Thanks & Regards
    Anup Shrivastava.

  119. MANJUNATHA says:


  120. Praveen says:

    Hi Joe,

    Example explained the whole concept clearly . Thanks a lot .

  121. Anonymous says:

    Excellent Example

  122. shivanand says:

    really great work sir…

  123. Sudhir Rana says:

    Excellent Example

  124. Dushyant says:

    good one

  125. Darshan says:

    really gr8 work

  126. Apurva says:

    Excellent differences….

  127. Yogendra says:

    Its really great difference…

  128. Anonymous says:

    Great example..thank u

  129. Anonymous says:

    Please provide Spring concepts also..

  130. Ganesh says:

    i like ur webSite.it id really helpfull

  131. Muruga says:

    It seems to be like a pictorial example. good work keep going

  132. Anonymous says:

    very nice explanation

  133. harjinder says:

    Nice explanation with example

  134. Deepak says:

    Very nice explanation with exaple

  135. shilpa says:

    I am a beginner in JAVA and the concepts explained here are very good and real life examples make it even more clear.

    i am lucky to have come across this website..
    its indeed really helpful…

  136. reshma begum says:

    Hi.. Nice example to understand better…:):):)

  137. Tekuri says:

    Hi Jo, Very good! Thanks a lot. keep it up…

  138. Anonymous says:

    Nice explanation

  139. bhaskar says:

    thank u …..

  140. Rajeev says:

    What a brilliant example.


  141. Dalayya says:

    What a wonderful example. I like this example. Thank you so much

  142. Kulanthaivelu says:

    Hi Boss.

    very thanks boss. Super example.

  143. Pramod Rajane says:


  144. vishwash says:

    Very Good explanation

  145. Kavitha says:

    Good Explanation


  146. prathip says:

    REALLY SUPERBBBB… No one can give example more than this…

  147. indu says:

    Simple & worthy explanation. Good Work!!

  148. pradeep says:

    tnx .

    its every easy to understand forward and redirect example

  149. Jeen says:

    good explanation with great examples… thank u..

  150. Anonymous says:

    Explained the concept clearly and in a very simple way. Good Work

  151. naveen says:

    good work..thanq

  152. Anonymous says:

    Very nice explanation in very simple language.

  153. Ravali says:

    Hi Joe,

    That was awesome explanation with the real time senario in simple language.

  154. rekha says:

    hello sir..

    itz really a very good explaination.. thank u so much sir..

  155. Anonymous says:

    S………….. of course it’s good

  156. Salim says:

    awesome example of class level and real time level.
    I am really impressed by this example

  157. Senthil says:

    Very nice explanation. Please keep posting these kind of explanations.

  158. Ramesh says:

    very good explanation with great examples… thank u..

  159. Anonymous says:

    good explanation ………Thank q….

  160. Mujeeb says:

    very nice Explanation ,,,,,,,,,,,

  161. Muthu says:

    Good one

  162. jagan says:

    Nice Explanation.:-)

  163. Anonymous says:

    nice article. bt when i tried, send ridirect is not working for other domains, i mean control is not going to the pages that are out of the web application

  164. Anonymous says:

    sorry,i got it.by using response.encodeRedirectURL(“destination”);

  165. pothis says:

    good work .. keep it up !!!!!!!!

  166. Java Learner says:


    Agreeing to all, nice example to explain.


    Can you please keep all your ‘thank you’/appreciation threads seprate or collapsable.

    Some ppl do post additional info and finding them b/w umpteen thankyou’s is difficult.

    Why not, assign a star on article, on evry appreciation recieved :)
    thats how notebook should look like , starry

  167. Anonymous says:

    Excellent defenition and example…Joe…

    Keep on posting….

  168. Joe says:

    @Java Learner, thanks for taking time to stop by comment. Let me see and fix it in the near future. :-)

  169. KOMAL says:

    i LIKED IT

  170. Anonymous says:

    Good Job Joe. I have good experience in java. i really liked the point ‘TO ACHIEVE SEPERATION OF TASK’ and the way you presented this point with example.

  171. SKS says:

    Good Job Joe. I have good experience in java but i really liked the point ‘TO ACHIEVE SEPERATION OF TASK’ and the way you presented this point with example.

  172. vijay says:

    Awesome Example you given!

  173. Anonymous says:

    Great Example… I really understand the concept of both redirect and forward..

  174. Anonymous says:

    servlet is threadsafe or not… I want to know this concept exactly.. can anyone explain this…

    • Niraj says:

      Servlet is not thread-safe by itself because of performance overhead. Prior to Servlet 2.0 to make it thread-safe you need to implement
      SingleThreadModel interface but its deprecated and can be removed from future version.
      You can make your Servlet thread-safe by making the service method synchronized.

  175. laxmi says:

    Love this.. Keep up the good work.

  176. Santhosh Kumar R says:

    Hi Joe you site is super and nice explanations to be understand by anyone. Admiring your interest in Java,

  177. gaurav says:

    excellent example but only one statement is wrong dear that is “Control can be redirect to resources to different servers ” in case of sendredirect we can forward the request to another web-app but they should run under the same server only.

  178. pankaj vaswani says:

    It was never clearer to me before.

  179. irfan says:

    very nice explanation :-)

  180. Neeraj says:

    Really its very good real world example,now i can’t forget it till my life:-)

  181. Sunil Sharma says:

    Really nice article.
    Very well example.

  182. Amit Agrawal says:

    Good Explaination

  183. Sunil kumar says:

    nice Example ..Thanks joe.i’ll never forget it.

  184. KarpovMohan says:

    Thanks Joe…
    Well explained !!!

  185. kanishka says:

    thanks plzzzzzzz help me in other topic also.

  186. Anonymous says:

    yeah this one….

  187. Tebar says:

    Very clear, Thanks a lot.

  188. viresh parikh says:

    Very clear example.

  189. hiren says:

    I loved the real world example.. good one!!

  190. Sangeetha says:

    Very catchy and interesting real world example. Thanks Joe

  191. FIroj says:

    Joe, u rocks …love dis blog ….keep up ur enthusiasm and good work …

  192. Anonymous says:

    nice real world example.good job.Thanks a lot

  193. neel says:

    does browser retains Cookies when redirecting to another domain?
    e.g. if Domain A sets a cookie in response before doing redirect to Domain B, will browser retain that coookie while creating new request for Domain B?

  194. Dinesh says:

    Please have this comment section with categories such as “Appreciations”, “Improvement” and “Q&A”.

    More over..It would be good if this comment section is expandable, rather than a long list on a single web page.


  195. prakash says:

    Hi Sir,

    Thanks for the wonderful explanation with examp. My doubt got cleared

  196. vivek says:


  197. arpit mishra says:

    Hi Joe
    You rock . only because of ur notes and real world example i got the job.

  198. sndpguru says:

    Thanks Joe for such an explanation, the answers in this website are class apart.

  199. Anonymous says:

    Awesome Article. Keep going.. thanks.

  200. Anonymous says:

    Awesome answer

  201. Hari says:

    hi,i have a doubt to use send Redirect method.
    when i implimented redirect method in my action class , how i hide parameters from users.

  202. shahid says:

    its very helpful to me in my mejor project making.thanks a lot

  203. pavan_krishna says:

    simple superb

  204. pavan says:

    Beatuiful example.! :)

  205. Minh says:

    I have wonder your statement:
    ‘session’ is not lost in both forward and redirect.
    Because I know session will be lost in redirect.

    Please correct me if i am wrong .

  206. dhanya says:

    The real time example cited here makes to understand the whole concepts.

  207. Anonymous says:

    Can you plz further elaborate this example in terms of session? What will happen to the objects that are stored as request attribute?

  208. JP says:

    Your realtime example narrated for this concept is simply superb.

  209. Vj says:

    Thank you!


  210. Anonymous says:

    Very good Example Dear friend….. Follow this ways… I understood easily..

  211. Shashi says:

    Good example.. this shows how to describe difficult scenario in an easy way !!!!!!!!!!!!!!!!

  212. ank_057 says:

    awesome example…..you changed my life…..thankk you!!!!

  213. Surya says:

    Excellent Example…!!!! now only i have got clarity between forward and sendRedirect techniques…!!! thanks a lot…!!!

  214. santosh says:

    Good Explanation with.. Good Examples.. really i like it..

  215. Jaffar says:

    Awesome stuff brother!God bless you!

  216. Anonymous says:

    really helpful and very clearly explained,thanx a lot.

  217. amrita says:

    could not help appreciating your way of explaining..it really made the concepts crystal clear…thank you… u rock..

  218. Nilesh says:

    Excellent Example

  219. chittaranjan padhi says:

    gr8 example….

  220. prasad says:


    very best example

  221. saurabh says:

    Thanks Joe.
    Superb example …!!!

  222. sweety says:

    Thank you. I liked the real time example. It made me understand the concept easily.

  223. Anonymous says:

    Excellent example.

  224. Punam says:

    I like the real time example very much..it’s really help me a lot…thank you very much joe

  225. deepak patidar says:

    A lot of Thanks, here real world example is very good,and i want to give thanks again for this.

  226. mani says:

    superb example

  227. Priya says:

    Very nice example. This site is very good, understandable.

  228. Sheeba says:

    brilliant exampleee!!!!

  229. sneha says:

    clear examples!

  230. Badal says:

    really great…thanks a lot..

  231. Deepa says:

    gr8 example…

  232. kumar says:

    very nice example joe.. thnx

  233. Mahesh says:

    Its very good answer… Thanks

  234. ankita says:

    fantastic example to understand the difference between forward an redirect

  235. parthimahesh says:

    this is very good examble…
    easily understand the difference.

    thanks a lot.

  236. sudha says:

    Thanks JOE

  237. sai ganesh says:

    Simple and straight explanation. Thanks.

  238. vvvv says:


  239. vvvv says:


  240. Shweta says:

    This is a really simple to understand !!

  241. muthus says:

    Thank you for such a simple explanation

  242. Anonymous says:

    Thank u sir….

  243. thomas says:

    Really good example

  244. Anonymous says:


  245. bachan says:

    nice example

  246. Deepak says:

    Its damn good explanation…

  247. prasadreddy says:

    good explanation

  248. Sharmi says:

    thank u so much for giving this simple example. ur explanation is realy very good.

  249. khasim says:

    you awesome man….brilliant explanation.

    khasim on july 30th,2012 2:28 am.

  250. khasim says:

    you awesome man….brilliant explanation.

  251. Gopal Gowda says:

    Nice explanation and good example too.

  252. Manikandan says:

    very nice example.great one too

  253. Ammu says:

    Gr8 explanation. Thanks for sharing

  254. sushree says:

    it makes me very clear about sendRedirect and Forward…thank u very much..

  255. Aman says:

    Milk man example are very good..
    thank u very much..

  256. chandu says:

    very nice example..

  257. ram says:

    it is very clear about it.

  258. akhilesh says:

    thanks a lot joe , really you have given great example which can help anyone….

  259. Anonymous says:

    Very nice explanation!!!!
    Thank you Joe :-)

  260. Bhushan says:

    Example of Dudhwala is awesome:) Please add some tutorial on jQuery, if you are expertise in it.

  261. Anand says:

    you are simply superb :)

  262. Anonymous says:

    Very good Explanation…

  263. Anonymous says:

    good example

  264. suma says:

    explanation was very clear

  265. fsffd says:

    Nice Explanation. Thanks a lot.

  266. Swati says:

    Really nice explanation .

  267. Anonymous says:

    Well explained

  268. Shakil says:

    Great example and very good explanation in simple words.

    like all your posts, keep up the good work!

  269. Khaleel says:

    Wow… what a great real time example….
    There exist @Joe.

  270. Khaleel says:

    There exist @Joe.

  271. Anonymous says:

    nice one.
    pooja on 6/9/2012 4:15 pm

  272. vino says:

    Excellent thanks

  273. vino says:

    Excellent thanks

  274. bala says:

    Very good explanation..

  275. swati says:


    Really it’s Great example.

  276. Ajay says:

    Excellent work !! thank you.

  277. Anonymous says:

    Thanks Yaar , finally i understood here in this website

  278. Konica Pal says:

    Good Explaination… Thanks

  279. mahendar K says:

    Great Explanation sir.learning fromm this explanation is like a cakewalk.

  280. Anonymous says:

    Hey thanks. I understood the concept now.

  281. srini says:

    Very good explanation, Now i understood a great sir,

  282. Chennakesava Reddy Vustalavaram says:

    Wonderful example Joe….

  283. Anonymous says:

    Thanks a lot….got idea on topic

  284. Nehal says:

    Wonderful example

  285. Anonymous says:

    Nice Website. Good Work.

  286. ajith says:

    i understood..crystal clear…

  287. Mangesh says:

    nice example

  288. Shashikant says:

    Excellent real time example.

  289. Aniruddha says:

    The difference u explained between forward and redirect is like a bulls eye…

  290. Janhavee says:

    The difference is superbly explained…hats offf..!!

  291. dipanshu says:

    Hi its really nice blog that you have maintained specially the example of forward and redirect was amazing.

  292. Anonymous says:

    Superb Article.I like the example.

  293. Rajkumar says:


    Very Nice ☻

  294. Jeevan says:

    Nice example

  295. krishna gupta says:

    nice explanation. thanks a lot

  296. Sutapa says:

    Thanks a lot.

  297. Lalitha G says:

    Well explained! Thanks!

  298. Pavan says:

    I liked the milk man example. It is fantastic. Understood the concept very well.
    Many Thanks,

  299. Priya says:

    Very easy to understand..luking forward for blog like
    oraclepapers from you :D

  300. Akshaya Gawand says:

    Thanks Joe! This helped!!

  301. Mahesh says:

    great explanation……..

  302. Anonymous says:

    Ok . fine..

  303. Anonymous says:

    fine example.. Keep up the good work…

  304. sagar says:

    excellent answear…………

  305. Saranya says:

    Really Superb explanation..!!

  306. Tarun S. Pandey says:

    Hi Joe, Nice examples you have given as well as explained. Your IRCTC example is also perfect. This also happens when we use Paypal Payment Gateway or similar. Good job!! Keep it up!! :)

  307. Anonymous says:

    Thank you so much .. you explain concepts so well

  308. santhanam says:

    Thankyou joe,
    Your real time example is easy to understand by us.keep give this type of real time example to other subject also …
    all the best.

  309. Jayesh Kalkani says:

    this is the best tutorial for all the beginners who have doubts in forward and sendRedirect…
    thank u very much….

  310. vikash says:

    Excellent… mind blowing…Very good explanation with extremely good example.

  311. Anonymous says:

    Nice explanation yaar.

  312. shiva says:

    Hello boss
    good example its really nice piece of example.

  313. hari prasad reddy says:

    Amazing real world Example,please provide this type of examples to other topics also.It is easy to understand.

  314. fuNi says:

    Nicely said

  315. Rana says:

    Really a very good example boss

  316. Vish says:

    Cool stuff! Really liked the milk man example :-)

  317. Snehit says:

    Very good explaination with real world examples.Good job.

  318. Manoj Patil says:

    nice example

  319. Venkat says:

    I have a query.

    I have a jsp with all costants.I want to use those value in a servlet(which calls by the web.xml at the loading the server).

    How can I achive this?

  320. Priyam says:

    Hi Amigo,

    really good example and simple to understand.

  321. Anonymous says:

    Nice Explination Joe

  322. Snehal says:

    Amazing example. It helped to understand the tricky part in simple way. Thank You

  323. Jay says:

    Brilliant work… Thanks

  324. Anonymous says:

    Good Discription

  325. Anonymous says:

    Good Description

  326. sri says:

    Good explanation with a simple example

  327. vignesh says:

    A good one with an apt example..!!

  328. sudarshan says:

    Nice example

  329. chethan says:

    Nice description about the difference between forward and redirect. Can u plz help me to get information and working about collections in java from basics. If u have any materials for that, Plz send me to my mail ID mentioned here. Please do helpfull. Thanks in advance..

  330. pradeep says:

    nice example!! thanksss :-)

  331. abhishek says:

    mast………but i m expecting one example program for forward and request….

  332. Sathish Kumar Mani says:

    Your examples are awesome. I liked it no no I admired it

  333. Deepika says:

    its very awesome answers. by this answers i qualified google’s interview. thank you so muchl

  334. Deepika says:

    its very awesome answers. by this answers i qualified google’s interview. thank you so much.

  335. vijay says:

    hi…very nice..really your every post is useful…thanks.

  336. ramesh says:

    I think we also can switch from one domain to other by using Context level RequestDispatchers forward() method.

    Let me correct if I wrong!!!!

  337. sasi says:

    Really thanks , its very helpful for beginners..excellent definition and example

  338. Rose says:

    thanks :)

  339. Anonymous says:

    I am really happy with your simple for forward and sendredirect

  340. Peerbasha says:

    I am really happy with your simple for forward and sendredirect

  341. vishal biradar says:

    simply great….

  342. SasikumarDuraisamy says:

    Thanking y sir,you are very good Teacher…

  343. Yash says:

    Joe.. You have explained it very well..

  344. Dharmendra says:

    Really a very good explanation..with real world and practical scenarios.


  345. Amit says:

    It really gives a clear concept….without the real world implementation it really becomes confusing

  346. Anonymous says:

    nice explanation..

  347. Anonymous says:

    thank you verymuch…it was really helpful to understand the concept.

  348. suranjan says:

    thank u again

  349. Anonymous says:

    examples plzzz

  350. sathya says:

    wonderful explanation

  351. Manoj says:

    Hello Joe,
    The example given to this topic is good. Many of them who do programming does not know which one to access because they have not been given the scenario examples. Even in my days of going to java course they didn`t think of giving the examples simply they said this is the syntax, you need to use like this. How can one understand when? where? how? why? to use the concepts of prgmming language. It is best desirable to give examples rather than teaching long hour periods. I think you have done a great job and if possible give examples like the said above to all the concepts blogged in this website.

  352. ramna says:

    1st time ever understand basic diffidence in two year java exp

  353. Naruto says:

    Nicely explained. Speaking of forwards and redirects, can you please explain the owasp top 10 security vulnerabilities? Its quite confusing for me to understand those in owasp or the others. I really look forward about you explaining about those ten!

  354. Mahima says:

    Thank you,finally i got the difference between redirect and forward

  355. Ravitheja says:

    Hi joe, example taken to explain this topic is fantastic… thank you, thanks a lot.

  356. Ahmad says:

    Really this a very good Blog

  357. Anonymous says:

    Excellent Explanation

  358. Bharath says:

    Very clear explanation. Thanks!!

  359. Prashant Agarwal says:

    Awesome Explanation !!!!!!!!!!!!

  360. Venky says:

    Awesome Example. Got clear information about sendRedirect() and forward() methods. Thanks alot :)

  361. Anonymous says:

    superbbbbb explanation…. thanks alottttt

  362. Manav says:

    Sir. you have definitely made our lives easy. Learning Java was never so enjoyable.

  363. Anonymous says:

    Hi Joe,
    Thanks for the explanation, I have a question. Other than session is there any way that we can transfer data across requests?

  364. Abdul Rahman says:

    Fine real world example. It was happen in my life.

  365. Manikantan says:

    Good Real world example :)

  366. keval says:

    very good and impressive example.

  367. shakti says:

    i think the forward example is little confused.according to the eg.. if u ll give the money to milkman that means the servlet-1 getting the result from servlet-2(Mother) and send d response to the request(milkman)….THIS IS THE EXMPL OR INCLUDE…THANK U.

    • shakti says:


    • shakti says:

      In forward() the servlet-1 forward the request to another servlet-2.the second servlet-2 to whom u forward the request ll send the response to the request not the servlet-1.

  368. priyanka says:

    Awesome Example Joe

  369. Satheesh Kumar s says:

    SuberB!!!!! Real world example!!!! joe

  370. Anonymous says:

    Explained in best way.. Thank you.

  371. Dayanand says:

    superb Joe

  372. Anonymous says:

    Excellent Material.

  373. Anonymous says:

    very nice explanation and nice example

  374. online loans says:

    Cheque Financial Loan: Most Best Way Of Possessing Money
    Thomas Alva Edison was born in Milan, Ohio in 1847.
    But, there is also a legend that he was born in Lagos de Moreno in Mexico and was taken to the United States as a toddler and adopted into the Edison loved ones.

    The legend, true or or else, testifies, at the very least, to the intercontinental
    veneration that this most prolific inventor enjoys until today.
    Who wouldn’t want to declare Edison as a indigenous son?
    Typically, an unexpected emergency problem like a damaged toilet would leave you pondering how you’re going to satisfy that invoice as nicely as all your other month to month outgoings.
    Unforeseen situations can make a big hole in your money reserves and the only preceding options had been high-priced, unauthorised overdrafts or credit history playing cards with superior
    month-to-month curiosity fees. Nevertheless, there
    is now a rapid, simple choice in the form of payday financial loans.
    A payday financial loan is a short-expression financial
    loan for a compact total -which functions as an progress on
    your regular every month or fortnightly pay back online loans.

    It really is an simple, hassle-no cost way to getting a bit of additional dollars promptly to bridge the gap concerning your speedy
    wants and your next pay back cheque.
    The IRS advises that you hold out at least seventy two hours right before examining on the standing of your
    refund if you filed electronically, and 4 weeks if you mailed in your return.

    So go forward and get your very own US Bank account now.
    Do not wait around till tomorrow as the legal guidelines are constantly switching.

    What is attainable now may not be achievable tomorrow.
    ACT fast. Good Luck.
    Some ladies might discover that ovulation does not return after they discontinue start command tablet use.
    If you do not encounter a menstrual interval in two to 3
    months after you have quit making use of the
    capsule, the American Being pregnant Affiliation recommends that you just take a being pregnant take a look at and speak to
    your health care provider. Having said that, it is crucial to preserve
    in intellect that the reason that ovulation does not return is
    usually unrelated to the tablet.
    Small business bills incurred up to seven decades prior to trading
    really commencing can be deducted from small business turnover if these fees
    had been solely for the upcoming business reasons.
    Enter such expenses in your accounting data as if they had been incurred on the initially working day of investing but clearly show the true acquire day.

    Lastly, even though it may perhaps be feasible to do all of
    this yourself, for your possess sanity and peace of head, you should really uncover a highly regarded and suitably qualified independent
    adviser. One who can offer you you suggestions that will be pertinent to you, your possess circumstance and necessities as effectively as chat
    points through with you your household and your other advisers (solicitors, accountants etc) where relevant.

    On the brick provider internet site, you will locate some specific gives.
    Just one of the distinctive features is receiving “cheap Bricks”.

    Low-priced bricks incorporate previous stock bricksthese are
    of superior excellent but have been in the manufacturer’s stock for a extended time, hence the packaging could be little soiled. An additional type of low-priced bricks is discontinued bricks where by some stock of the bricks is obtainable whose output has stopped.
    Claim business expenditures incurred prior to trading. Edison moved to New York Town when he was 20-two several years previous.

  375. Anonymous says:

    super example

  376. Lokesh Guru says:

    Good and easy example. Keep doing good work

  377. Nithin J Pathalil says:

    Just wish to tell u that the real world example was great.. Got the idea from the example.

  378. Anonymous says:

    examples gives brief idea.

  379. Rajasekhar says:

    Nice explanation and awesome example ha ha ha..

  380. Rajasekhar says:

    Nice explanation..

  381. Somu Sundara Goutham says:


  382. swagatika panda says:

    The example given was too nice.I got a clear idea on the topic.

  383. Anonymous says:


  384. Asanka says:

    Great article..! Keep it up

  385. Anonymous says:

    Fantastic very good real time example..

  386. Anonymous says:

    thanks, nice explanation

  387. Tushar says:

    Nice explanation …… Thanks :)

  388. Anonymous says:

    awesome style to explain this scenario,

  389. Vishal Desai says:

    nice explanation

  390. narayana says:

    Nice Eamples.

  391. Anonymous says:

    Nice Exxplanation!! . Thanks

  392. D N Ashok says:


    A very good clarification….


  393. Surendra says:

    Useful information… Thanks Joe.
    Your way of explanation is simply superb.

  394. Anonymous says:

    super bro..!!

  395. Anonymous says:

    Gr8 work..Thanks for ur article..

  396. Anonymous says:

    explanation is given by one tech lead …..
    hehehehe now i got it….

  397. S says:

    Very good example

  398. Aditya says:

    Hi Joe,

    Really, you had posted a Excellent topic
    The touchy part of the article was the Milk Man example.

    Thanks a Lot for your Effort.


  399. abdulrahim says:

    i like real world example .

  400. sachin says:

    I like your examples joe….

  401. Vel SR says:

    Thanking you. Your my best java teacher..

  402. suresh says:

    thank u joe……..

  403. Adrita Ghosh says:

    I searched for this in many websites but the explanation given here is awesome. In simple words,described the best.Thanks a lot Joe sir.:)

  404. sam says:

    Nice Answer in simple word


  405. Jackin says:

    Excellent example too good

  406. Hemanth says:

    very good Explanation
    thank you

  407. Manju says:

    seriously great example……

  408. Ajay says:

    Excellent way of explaining it!

  409. Ashish says:

    Excellent work and excellent way of teaching by example.
    Thanks Joe

  410. Anonymous says:

    thank u

  411. Anonymous says:


  412. Vishwas says:

    Simply superbhhhh…..What an example !!!!!

  413. Anonymous says:

    For example, if i pay electricity bill in online, i have to pay the money through netbanking, can we say it is happening through redirect, then how the bill amount is getting displayed in netbanking site without a response/request.

  414. Devendra says:

    No doubt you are doing revolutionary work.
    Here I would like to suggest to you. Include practical examples with your theoretical explanation that make it absolute.

  415. Dilip Senapati says:

    Excellent. Well explained.

  416. Anonymous says:

    Than you very much…….

  417. Pavle says:

    Excellent example!

  418. Ana says:

    Example made my redirects and forwards solid..

  419. Anonymous says:

    Thanx.The way of explaination is superb!! through good example.

  420. Pawel says:

    Good job Joe!

  421. Anonymous says:

    Great Explination Joe.
    Appreciate your work.

  422. Yogesh says:

    Excellent example very well understand.Thanks sir

  423. Zulfikar says:

    Best explanation with example

  424. Ashwini Kumar Patro says:

    i want to know which one is faster in execution forward() or redirect ()?

  425. Binh Thanh Nguyen says:

    Thanks, nice post

  426. Anonymous says:

    I like your real world example. Thanks for sharing informatiiion

  427. Rashmi says:

    Thanks joy ….very clear example …easy to understand

  428. sapphire says:

    Great stuff

  429. Anonymous says:

    Very good example

  430. Satya Neeli says:

    Nice Example!!!

Leave a Reply