simply response.sendRedirect takes user to another page. mostly its enough for forwarding browser to somewhere else from user perspective but what about google bot and other search engines. PR is not a easy thing to earn. and not affordable thing to loose.
anyway back to the topic. let say we are redirecting clients for subdomains to the other folders. like this:
faq.domain.com -->> faq.domain.com/faq/
in this situation we should use sendRedirect but that function uses HTTP 302 for the response status it means moved temporarily. as a result if you got any link from pr5 to faq.domain.com you will loose it. because google bot will say that this is a temporarily issue then I should not give this pr to that page.
how can we gain back that pr. you shoul use these lines for redirect:
response.setStatus(301);
response.setHeader("Location",newUrl);
if anyone who wonder about the real implementation of sendRedirect here:
public void sendRedirect(String url)
throws IOException
{
if (url == null)
throw new NullPointerException();
if (_originalResponseStream.isCommitted())
throw new IllegalStateException(L.l("Can't sendRedirect() after data has committed to the client."));
_responseStream.clearBuffer();
_originalResponseStream.clearBuffer();
_responseStream = _originalResponseStream;
resetBuffer();
setStatus(SC_MOVED_TEMPORARILY);
String path = getAbsolutePath(url);
CharBuffer cb = new CharBuffer();
for (int i = 0; i < path.length(); i++) {
char ch = path.charAt(i);
if (ch == '<')
cb.append("%3c");
else
cb.append(ch);
}
path = cb.toString();
setHeader("Location", path);
// The data is required for some WAP devices that can't handle an
// empty response.
ServletOutputStream out = getOutputStream();
out.println("The URL has moved <a href=\"" + path + "\">here</a>");
// closeConnection();
if (_request instanceof AbstractHttpRequest) {
AbstractHttpRequest request = (AbstractHttpRequest) _request;
request.saveSession(); // #503
}
close();
}
Subscribe to:
Post Comments (Atom)
sony xperia 10 VI did not like the case
After iphone 16 I wanted to test an android and looks like sony xperia 10 VI is nice, which is 6.1 inches, but it was narrow and longer than...
-
if you have wl11 ejb server and in that environment generated ejb client and deploy to wl12 it will give you this exception java.lang.NoSu...
-
Yeni nesil hacker'lar: Edwin Pena | Olympos Security koptum okuyunca yazılımcılar ve pazarlamacılar bu kadar kısa ve özlü bir hikayeyle ...
-
I know its been a long time I have not write anything. because I have not learn or done any new things. I dont want to write regular meaning...
No comments:
Post a Comment