Hi Thiago, I'm assuming you mean something like this, but I'm not seeing
the 301 response. Could you take a look and see if you can spot what I'm
doing wrong. Below is the response as well. Thank you.


public class AccessController implements Dispatcher {

@Override
    public boolean dispatch(Request request, final Response response)
throws IOException {
        int port = request.getLocalPort();

        PageRenderRequestParameters parameters =
linkEncoder.decodePageRenderRequest(request);

        if (port == 80) {
            Link link =
linkSource.createPageRenderLinkWithContext(parameters.getLogicalPageName(),
parameters.getActivationContext());
            response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
            link.setSecurity(LinkSecurity.SECURE);
            response.sendRedirect(link.toAbsoluteURI());
            return true;
        }

        componentRequestHandler.handlePageRender(parameters);
        return true;
    }

AppModule.class

public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher>
configuration,
            @InjectService("AccessController") Dispatcher accessController)
{
        configuration.add("AccessController", accessController,
"before:PageRender");
    }

public void contributeMetaDataLocator(MappedConfiguration<String, String>
configuration) {
        configuration.add(MetaDataConstants.SECURE_PAGE, "true");
    }


http://localhost/etss

GET /etss HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101
Firefox/32.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://localhost/
Connection: keep-alive

HTTP/1.1 302 Found
Location: http://localhost/etss/
Content-Length: 0
Server: Jetty(8.1.14.v20131031)
----------------------------------------------------------
http://localhost/etss/

GET /etss/ HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101
Firefox/32.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://localhost/
Connection: keep-alive

HTTP/1.1 302 Found
Set-Cookie: shiroSavedRequest=/etss/;Path=/etss
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Location: http://localhost/etss/login
Content-Length: 0
Server: Jetty(8.1.14.v20131031)
----------------------------------------------------------
http://localhost/etss/login

GET /etss/login HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101
Firefox/32.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://localhost/
Connection: keep-alive

HTTP/1.1 302 Found
Location: https://localhost/etss/login
Content-Length: 0
Server: Jetty(8.1.14.v20131031)
----------------------------------------------------------
https://localhost/etss/login

GET /etss/login HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101
Firefox/32.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://localhost/
Connection: keep-alive

HTTP/1.1 200 OK
Content-Type: text/html;charset=UTF-8
Content-Encoding: gzip
Transfer-Encoding: chunked
Server: Jetty(8.1.14.v20131031)

On Tue, Oct 28, 2014 at 6:53 AM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Tue, 28 Oct 2014 04:30:45 -0200, George Christman <
> gchrist...@cardaddy.com> wrote:
>
>  it appears as if the redirects are happening automatically without a 301.
>> Does anybody know how I can accomplish this task?
>>
>> When I move pages, I generally just use something like this.
>>
>> Link link = linkSource.createPageRenderLinkWithContext(Signin.class);
>>         return new HttpStatusCode(HttpServletResponse.SC_MOVED_
>> PERMANENTLY,
>> link);
>>
>
> Write a Dispatcher and contribute it before the other ones. Use
> ComponentEventLinkEncoder.decodePageRender() to know what page and
> activation context then use PageRenderLinkSource to create the URL to
> redirect.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

Reply via email to