• Post Reply Bookmark Topic Watch Topic
  • New Topic

Two questions for Mr. Peter den Haan please

 
ziqiang wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter:
Could you please tell me
1)what difference between req.getRequestDispatcher("address") and res.sendRedirect("address")?
2)How to set html head to protect the page from catched?
Thank you Peter!
Wu
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could answer, but I'm not Peter.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Mike - personal questions are best asked by e-mail. And, to be perfectly honest, I tend to ignore e-mailed questions unless I understand why they haven't been posted in a forum.
But enough of that. The difference between forwarding and redirecting is this. Forwarding is completely internal to the server; it's a way for one servlet to call another servlet. A redirect sends a response back to the browser telling it to retrieve the given URL. In practical terms, this means
  • A redirect will show up in the browser's address bar, a forward won't as the client is as unaware of the forwarding process as of any other Java method call.
  • In a forward, request attributes are preserved; in a redirect, they aren't as a redirect tells the browser to send a completely new request.
  • A forward is generally more efficient than a redirect.
  • A forward can only go to another resource running on the same server; a redirect can tell the browser to go absolutely anywhere.
  • Protecting your page from caching is notoriously hard. Formally, it should simply be a matter of setting the "Pragma" response header to "no-cache" (for HTTP/1.0 clients) and the "Cache-Control" header to "no-cache" (HTTP/1.1 clients). But in practice this is ignored by buggy proxy implementations (one Bill G. is the major culprit here - surprise, surprise - small wonder: if there's one company you can trust to ***** up whatever they do...). Even setting the "Expires" header to "0" is not completely Bill--- I mean fool-proof. A workaround is to generate a unique parameter (e.g. timestamp) for every request. There is another workaround that is supposed to be bomb-proof, something to do with sending back error response codes, but I lost track of it. Anyone?
    Read RFC 2616 to learn more about HTTP headers.
    HTH
    - Peter
    [This message has been edited by Peter den Haan (edited November 03, 2001).]
 
ziqiang wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Peter! you are real professional.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks -- you might want to review this thread:
http://www.javaranch.com/ubb/Forum7/HTML/006558.html
it discussed the same issue, but gave a little more detail beyond what Peter's said in this thread.
Kyle

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!