[MAGNOLIA-1938] Redirect doesn't work properly in mail sample Created: 08/Dec/07  Updated: 23/Jan/13  Resolved: 10/Dec/07

Status: Closed
Project: Magnolia
Component/s: samples
Affects Version/s: None
Fix Version/s: 3.5

Type: Bug Priority: Critical
Reporter: Tom Jensen Assignee: Philipp Bärfuss
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

sun 1.5.0_07


Issue Links:
dependency
depends upon MAGNOLIA-1964 Use forward() in JspTemplateRenderer ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Here are the steps:

1) downloaded the latest tomcat bundled Magnolia from sourceforge (rc3)
2) started up using Sun JDK 1.5.0_07
3) configured smtp server
4) opened sample mail form and configured form properties
5) filled out form and submitted

At this point I received the e-mail from Magnolia just fine but the page in the browser maintains the mail form's url (http://localhost:8080/magnoliaAuthor/mailform.html) and the HTTP redirect is never sent from the server. I double checked to ensure that it was pointing to a valid page for the redirect. I've also tried this in both Firefox and IE.

I've also tried this off of the latest code from the trunk and I get the same problem. When I step through the code the problem seems to be a flag called include that gets set in the ApplicationHttpResponse object in tomcat to true. I don't understand tomcat internals enough to know what's going on so that's where I stopped. I did try this on my own jsp template where I put a redirect in and it never sends the redirect (same reason). I'm assuming that it isn't a tomcat issue though.



 Comments   
Comment by Philipp Bracher [ 10/Dec/07 ]

In tomcat (5.0, 5.5) the redirect doesn't work after an include because org.apache.catalina.core.ApplicationHttpResponse does the following:

public void sendRedirect(String location) throws IOException

{ if (!included) ((HttpServletResponse) getResponse()).sendRedirect(location); }

I don't know if this is by spec and redirects do as well fail in other containers.

The change was done in the process of implementing MAGNOLIA-1698 and can not be easily reverted.

Comment by Philipp Bracher [ 10/Dec/07 ]

In JSP spec (2.0) point 5.4:

"An included page cannot change the response status code or set headers. This precludes invoking methods like setCookie. Attempts to invoke these methods will be ignored. The constraint is equivalent to the one imposed on the include method of the RequestDispatcher class."

Comment by Philipp Bracher [ 10/Dec/07 ]

I will solve that by doing the following:

  • change the TemplateRenderer to use a forward instead of include
  • add support for a special request attribute which is used for bypasses (this attribute is then set by the TemplateRenderer)
  • add a main bypass which does bypass the complete filter if the attribute is set
Generated at Mon Feb 12 03:31:47 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.