[opencms-dev] How do I send a 301 redirect in OpenCms???

Daniel Rhoden drhoden at iiwinc.com
Fri Nov 11 19:57:37 CET 2005


All of the ways that I have read how to send a 301 permanent redirect 
from a JSP fail in OpenCms.  The page always returns 200 Status OK.

I am using 6.0.2.  Is this related to the issue of Error pages return as 
200 instead of 404?

How can I get around this?

--Daniel Rhoden


Here is the JSP I am using:

<%@ page import="java.util.*,org.opencms.file.*,org.opencms.jsp.*" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<jsp:useBean id="cms" class="org.opencms.jsp.CmsJspActionElement">
  <% cms.init(pageContext, request, response); %>
</jsp:useBean>
<c:set var="target"><cms:link><cms:property name="target"/></cms:link></c:set>
<%
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
String newLocn = response.encodeRedirectURL( (String)pageContext.getAttribute("target") );
response.setHeader("Location",newLocn);
%>
<%-- <c:redirect url="${target}"/> this is a temporary redirect--%>

<b>Hello</b><%-- this should not appear but it does --%>




More information about the opencms-dev mailing list