[MAGNOLIA-324] Using jsp:directive.include for JS Files is Incorrect Created: 11/Apr/05  Updated: 17/Mar/09  Resolved: 30/May/05

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

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

Resin 3.0.12. Tomcat might ignore this error and continue gracefully.


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   

According to the JSP specification:

========================
JSP.5.2.4 The jsp:directive.include element

The jsp:directive.include element is used to substitute text and/or
code at JSP page translation-time. This element can appear anywhere
within a JSP document. Its syntax is:

<jsp:directive.include file="relativeURLspec" />

The interpretation of a jsp:directive.include element is as in Section
JSP.2.10.3. The XML view of a JSP page does not contain
jsp:directive.include elements, rather the included file is expanded
in-place. This is done to simplify validation.
========================

As a result, the JavaScript files are being parsed as XML before being inserted. Since they AREN'T XML files, parsing fails:

[09:17:07.553] /admintemplates/js/../../admindocroot/js/i18n.js:56: expected `>' at ``;'' (for tag `<args.length>' at line 56). The XML tag syntax is: <tag attr1='value1'>

The fix, fortunately, is not so difficult. If you really want to use jsp:directive.include, all the included JSP files must be enclosed in CDATA tags.



 Comments   
Comment by Titus Barik [ 12/Apr/05 ]

Actually, this won't solve the problem. We can't do a straight CDATA block around everything because of the ${pageContext.request.contextPath} call. Possibly use jsp:include instead of jsp:directive.include.

Comment by Philipp Bracher [ 30/May/05 ]

CDATA does not work, because the resulting js wouldn't be valid

jsp:include does not work, since this calls the Spool servlet and the Spool servlet writes directly on the stream --> an exeption is throwed

There are three solutions possible:

a) move to the old jsp syntax (only for js)

b) moving the included files from admindocroot to admintemplates (this avoids calling the Spool servlet)

c) including each file separately in the page in which they are used

Comment by Philipp Bracher [ 30/May/05 ]

I moved the js/admincentral.jsp and js/dialogs.jsp to the standard jsp syntax (not jspx). It does not make sensen to use an xml syntax for generating a non-xml file.

Additionaly i made all javascripts in the admindocroot static (they use now a global contextPath variable)

Generated at Mon Feb 12 03:16:18 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.