Hi Kalle, would you still be setting the status header in the dispatcher? On Tue, Oct 28, 2014 at 2:30 PM, Kalle Korhonen <kalle.o.korho...@gmail.com> wrote:
> The problem is that the status header is rewritten - sendRedirect() > implicitly sets 302 by the spec. Set the headers yourself and flush to > commit: > > > servletResponse.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); > servletResponse.setHeader("Location", > servletResponse.encodeRedirectURL(requestUri)); > servletResponse.flushBuffer(); > > Kalle > > > On Tue, Oct 28, 2014 at 11:18 AM, George Christman < > gchrist...@cardaddy.com> > wrote: > > > I found componentRequestHandler in some tapestry code and when I removed > > it, no page. I guess I just needed to return false ;) > > > > Yup the code is definitely running, I can remove Secure_Page and the page > > redirects without issue, however no matter what I setStatus too, it > > continues to provide a 302 response. If I sendError to a 301, it will > > redirect the browser to a 301 error like it should. Is setStatus the > > correct method to use? > > > > http://localhost:8080/etss/login > > > > GET /etss/login HTTP/1.1 > > Host: localhost:8080 > > 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 > > Cookie: shiroSavedRequest=/etss/ > > Connection: keep-alive > > > > HTTP/1.1 302 Found > > Location: https://localhost/etss/login > > Content-Length: 0 > > Server: Jetty(8.1.14.v20131031) > > > > > > On Tue, Oct 28, 2014 at 1:42 PM, Thiago H de Paula Figueiredo < > > thiag...@gmail.com> wrote: > > > > > On Tue, 28 Oct 2014 15:11:13 -0200, George Christman < > > > gchrist...@cardaddy.com> wrote: > > > > > > Hi Thiago, > > >> > > > > > > Hi! > > > > > > 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. > > >> > > > > > > Are you sure your code was actually called? > > > > > > > > >> > > >> 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; > > >> > > > > > > You should return false when a Dispatcher didn't provide a response, so > > > the last line should return false, otherwise no page will ever be > > rendered. > > > I'm not sure why you've added the componentRequestHandler line. > > > > > > > > > -- > > > 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 > > > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York