Thanks, the PermanentRedirectResolution does the trick. I'd be in favor of
adding something like this if the stripes community was so inclined to add
it, with the current constructors continuing to issue temporary redirects:
public RedirectResolution(String url, boolean permanent)
On Mon, Jul 13, 2009 at 9:14 AM, [email protected] <[email protected]> wrote:
> Ray,
>
> Several months ago I wrote a resolution to handle permanent redirects. The
> redirect was dependent on information in the database thus I was not able to
> outsource this to httpd.
>
> The code is attached; feel free to use it.
>
> Also, to those in the Stripes community, would it make sense to add support
> for permanent redirects to Stripes? Perhaps this could be added as an
> option on RedirectResolution? If so, I would be happy to add the issue to
> JIRA and create a patch.
>
> Best,
> Andy
>
>
>
> Stone, Timothy wrote:
>
>> Without writing your own Resolution, e.g., PermanentRedirectResolution,
>> you might try:
>>
>> 1. a ForwardResolution to a resource that generates your 301
>> 2. a ForwardResolution to a resource that performs mapped lookup in
>> Apache (or other HTTPD), using a query or path element, for a 301.
>>
>> Writing your own Resolution, extending RedirectResolution, overriding
>> the execute method, seems plausible. In order of complexity, it might be
>> the most complex, with #1 being the easiest, IMHO.
>>
>> Regards,
>> Tim
>>
>> -----Original Message-----
>>> From: Ray Vanderborght [mailto:[email protected]] Sent: Sunday, July
>>> 12, 2009 12:40 AM
>>> To: [email protected]
>>> Subject: [Stripes-users] Permanent redirect?
>>>
>>> Is there a way to do a permanent (301) redirect from inside a stripes
>>> action?
>>>
>>> What I'm doing is adding keywords to the end of my urls for better SEO,
>>> and I'm redirecting existing urls to the new ones with the keywords added.
>>> I'm using a RedirectResolution now to accomplish this but it's issuing a
>>> temporary (302) redirect instead of a permanent redirect.
>>>
>>> This article on a related topic (the canonical tag) mentions a 301
>>> redirect as being the right thing to do in this case:
>>> http://www.mattcutts.com/blog/canonical-link-tag/ (slide #4).
>>>
>>> Anyhow I'm not too hung up on it, but if there's a way to do a permanent
>>> redirect that I'm just missing let me know. Thanks.
>>>
>>>
>>
>> Barclays www.barclaycardus.com
>>
>> This e-mail and any files transmitted with it may contain confidential
>> and/or proprietary information. It is intended solely for the use of the
>> individual or entity who is the intended recipient. Unauthorized use of this
>> information is prohibited. If you have received this in error, please
>> contact the sender by replying to this message and delete this material from
>> any system it may be on.
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Enter the BlackBerry Developer Challenge This is your chance to win up to
>> $100,000 in prizes! For a limited time, vendors submitting new applications
>> to BlackBerry App World(TM) will have
>> the opportunity to enter the BlackBerry Developer Challenge. See full
>> prize details at: http://p.sf.net/sfu/Challenge
>> _______________________________________________
>> Stripes-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>
> import net.sourceforge.stripes.action.ActionBean;
> import net.sourceforge.stripes.action.RedirectResolution;
>
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import java.io.IOException;
>
> public class PermanentRedirectResolution extends RedirectResolution {
> public PermanentRedirectResolution(String url) {
> super(url);
> }
>
> public PermanentRedirectResolution(Class<? extends ActionBean>
> beanType) {
> super(beanType);
> }
>
> public PermanentRedirectResolution(Class<? extends ActionBean>
> beanType, String event) {
> super(beanType, event);
> }
>
> @Override
> public void execute(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> String url = getUrl(request.getLocale());
> String contextPath = request.getContextPath();
>
> if (contextPath.length() > 1 && !url.startsWith(contextPath
> + "/")) {
> url = contextPath + url;
> }
>
> url = response.encodeRedirectURL(url);
>
>
> response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
> response.setHeader("Location", url);
> }
> }
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users