Forum Moderators: open

Message Too Old, No Replies

JSP redirect/shortcut - how does it affect SEs?

         

tedster

8:50 am on Oct 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm wading into extremely unfamiliar and unexpected server side stuff with a new client and would appreciate some help.

They're running Apache with Tomcat on a Win NT4 server. They have an incredible tangle of redirects and map rules that come out of a file called "shortcuts.jsp" and they want to make some more.

I can already see some total nuttiness with their URLs on search engines, but I'm not sure where it all comes from -- I know absolutely ZERO about java.

So how does a jsp redirect affect search engines? Is this a "safe" way to create redirects as far as search engines are concerned?

ppg

12:47 pm on Oct 24, 2003 (gmt 0)

10+ Year Member



Don't know how much help this will be to you, but there's basically two ways of doing redirects server side in java.

The first one, using the servlet method sendRedirect() passes a 302 back to the browser.

The second, and the more likely in this case, is the jsp:forward directive - which calls the servlet pageContext.forward() method. This all happens server side, so the target file specified in the forward method is served back to the client without any extra requests being made. The original URL will still be displayed in the browser address bar.

In this case, I would assume that a search engine would be ok with this since it will index the target file rather than the redirecting one. But I'm guessing based on how these methods work. I've never used a set up like that.

Why all the redirects?

tedster

5:24 pm on Oct 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks ppg -- just that much sheds some helpful illumination. Indeed, it must be the second scenario, and that would explain the oddities I'm seeing in search engines as well.

Why all the redirects

Sometimes to set up a shorter, type-in URL for print. Sometimes just being much to casual with the URL name space. But basically, too many cooks in the kitchen and no head chef. And they main dish they prepared was spaghetti.

Some of the SE problems I see occur with subdomains. As you described, the URL in the location bar does not change. Then the next link from the new destination page is a relative link, and the original subdomain remains in the URL.

All this would be fine EXCEPT that the server has been misconfigured for months and the subdomains are all crossed up with each other. So now the search engine listings use sub1.example.com to point to the content of sub2.example.com -- and there are some very bizarre combinations of content and url.

Can we create 301 redirects in this scenario to sort things out?

ppg

10:30 pm on Oct 24, 2003 (gmt 0)

10+ Year Member



Again, I don't know if this info is going to help you out, but you can set response codes from jsp pages in a couple of ways:

<%
response.setHeader("SC_MOVED_PERMANENTLY", "http://www.example.com/newfile.htm");
%>
I tried this though, and the browser didn't follow the redirect.

<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location", "http://www.example.com/newfile.htm");
%>
This one works ok, it sends the 301 status code and the browser follows the redirect, but the URL in the address bar is still the original request, so I suspect you may still have the same problem with relative paths.

In both cases, SC_MOVED_PERMANENTLY is defined in the HttpServletResponse class as a static integer, 301.

There's more info on the HttpServletResponse object here: [java.sun.com ]

Sorry I can't be of more help.

tedster

12:56 am on Oct 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You've been immensely helpful -- although I still can't see the complete path forward, at least I have the sense that it's somewhere in a certain direction.

Any and all input is still very welcome from anyone.

[edited by: tedster at 1:05 am (utc) on Oct. 25, 2003]

bcc1234

1:04 am on Oct 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a piece of code that does 301 recirect for my affiliates' links:


response.setContentType("text/html");
response.setDateHeader("Expires", 0);
response.setHeader("Location", "http://" + SiteModel2.getProperty("SM2_HOST_NAME") + url);
response.setStatus(301);

Haven't had any problems with it.