sendRedirect and SEO in java

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();
}

Clickaider

I have been waiting about this. cliackiader is a freeservice under 100 thousands page view after that it says.

Current period includes more than number of clicks allowed for youraccount (100,000).
You can view current report starting from 02/25/2008 00:00.

its nice to see that we overwhelmed the possible ways 🙂

Vista is a total disaster or what

some part of my program could not work on vista. it says “no authorization”. this program developed under .net 2 simple program shows some web pages from internet stands in system tray. thats the program in this post.

and it uses webbrowser component of .net. I know microsoft build up a new most secure system for their customers. but it works in XP. there must be some option about vista situation. now I am thinking C++ will be more easy but I am not sure. anyway time will show.

Funny Eclipse

I have been working with all platforms about 15 years now. I used to write bat files in dos5 now I am writing java code with eclipse and c# with vs.net . anyway here is the story about the funny ide 🙂

I was writing some AJAX application in eclipse which has to call a ten thousand line js file from browser and call some function from there. first of all writing that much big js file is a big big mistake from all perspectives. and deploying this big file to a browser another mistake but its a big project since 2006 its written by some people. I can not change that in 1 day.

when I start to turn mouse wheel eclipse understands later the effect and when I stop it could not stop 🙂 and line numbers comes later too. it means I have to a lot of CPU and RAM for that. but its like walking with a big dog 😀

NotifyIcon and double click problem

in .net 2 if you want to show your application in system tray. you need to add notify icon to your application and set the “ShowInTaskBar” property to False. now you have the notify icon in the system tray. my problem was I could not show the form if I double click on the notify icon. I tried to BringToFront() which works but it did not work under this situation. anyway here is the solution:

private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Visible = true;
Show();
this.BringToFront();
this.Activate();
}

I know that bringtofront function does not work but I like to see my code this way more clear 🙂 now Activate() works perfectly.

Change Php Memory Limit in Shared Hosting

One of my client asked me to solve a small bug in one of my php application. I am not a php guru but I am a dirty hacker 🙂 anyway the problem was exceeding memory limit. in shared hosting it was limited with 8M from php.ini

I made a small research but could not find any document about it in ISP’s page. and asked to my uncle google. he could not find any copy paste code there too 🙂 and at last of course for the php I have to check php.net and its documentation little bit reading here is the line which saves the day:

ini_set(‘memory_limit’,’128M’);

it was working very fine in 8mb then it will work for a long time in 128m 🙂 thats enough for that.