Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behavior of the c Tag between version 17 and version 18 in OpenCMS #808

Open
rgaviras opened this issue Nov 6, 2024 · 3 comments

Comments

@rgaviras
Copy link
Contributor

rgaviras commented Nov 6, 2024

Here's a simple example of the issue:

We have a resource with a formatter like this:

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:redirect url="https://www.google.com"/>

In version 16, if the resource is on a page, the redirect works as expected. However, in version 18, this fails and returns the following error on the page:

Error parsing element /en-en/page/.elements/Banner_00001.xml. Please check if the HTML generated by the element formatter is well formed.

image

To test this, it’s recommended to first create the formatter without the redirect; otherwise, it won't allow you to drag it onto the page, whether it works or not.

This is just a sample to replicate the issue. In the actual case, this code is within a function that performs the redirect based on specific logic.

@rgaviras rgaviras changed the title Different behavior of the c Tag between version 16 and version 18 in OpenCMS Different behavior of the c Tag between version 17 and version 18 in OpenCMS Nov 6, 2024
@rgaviras
Copy link
Contributor Author

rgaviras commented Nov 6, 2024

I've tested on OpenCms17 and works as expected... the diference is on version 18

@rgaviras
Copy link
Contributor Author

Does anyone know or can think of an alternative to bypass this error? Or any hints on where to look?
We're a bit lost, and a large part of our development depends on a method like this.

@chemajf
Copy link

chemajf commented Nov 25, 2024

Hello,
Problem:
I have debugged the code from the TAG Builds_18_0 and I believe the issue is in the method org.opencms.loader.CmsJspLoader#dispatchJsp, specifically in the last else if (line 1109):
image

In the case where the JSP is a dynamic function, the method controller.isTop() always returns false, which means the redirection is never performed even if it exists, and null is returned, causing the error.
I am not sure why controller.isTop() always returns false.

Patch:
To trigger the redirection, I modified the code so that if we have RedirectInfo and the redirection contains "http", it performs the redirection without checking controller.isTop():
image

If this condition is not met, the original check is performed as before.

I don't believe this is the proper solution, but rather a temporary patch to address this issue.

I hope this information helps in resolving the problem.

Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants