You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Roy Teeuwen <ro...@teeuwen.be> on 2016/10/12 16:11:51 UTC

Migrating from JSP to HTL/Sightly

Hey all,

For one of our current projects, we are in the process of making all the new components/templates in HTL instead of JSP. One of the things we did notice though is that when we use a component as resourceSuperType that still uses jsp, that in those jsp files we use the following as stated on how to use it in the docs[1]:

<sling:call script=“myscript.jsp”/>

This makes it that we can’t overwrite the myscript.jsp file by a myscript.html file because the script call specifically states myscript.jsp. Now I tried it out by removing the .jsp extension from the script attribute, and this seems to work! 
So my question now is, is there a reason not to do it this way? Why is it stated in the docs that you should say myscript.jsp instead of just myscript, seeing as myscript alone already works too and would have made it possible to overwrite the specific scripts by other template engines.

Greetings,
Roy

[1] https://sling.apache.org/documentation/bundles/scripting/scripting-jsp.html#call <https://sling.apache.org/documentation/bundles/scripting/scripting-jsp.html#call>

Re: Migrating from JSP to HTL/Sightly

Posted by Roy Teeuwen <ro...@teeuwen.be>.
Hey all,

Sorry for the bump, there is also a second issue that I would like to ask concerning the migration from JSP to HTL. We have versioned resource types in folders concerning the release date. For example /apps/myapp/1702/components/mycomponent

Now when switching to sightly, we get following exception:

org.apache.sling.scripting.sightly.impl.compiler.CompilerException: org.apache.sling.scripting.sightly.impl.compiler.CompilerException: org.apache.sling.scripting.sightly.impl.compiler.CompilerException: Compilation errors in apps/myapp/1702/components/mycomponent/SightlyJava_main.java:
Line 19, column 971 : The declared package "apps.myapp" does not match the expected package "apps.myapp.1702.components.mycomponent"
Line 19, column 981 : Syntax error on token ".1702", delete this token
    at org.apache.sling.scripting.sightly.impl.compiler.SightlyJavaCompilerService.compileSource(SightlyJavaCompilerService.java:143)

I guess this is because it translates the folders to package names, and 1702 is not a valid package identifier, but why isn’t it throwing this exception then in all your already existing jsp components? And is there a workaround for this or should I register a bug.

Greetings,
Roy
> On 12 Oct 2016, at 18:11, Roy Teeuwen <ro...@teeuwen.be> wrote:
> 
> Hey all,
> 
> For one of our current projects, we are in the process of making all the new components/templates in HTL instead of JSP. One of the things we did notice though is that when we use a component as resourceSuperType that still uses jsp, that in those jsp files we use the following as stated on how to use it in the docs[1]:
> 
> <sling:call script=“myscript.jsp”/>
> 
> This makes it that we can’t overwrite the myscript.jsp file by a myscript.html file because the script call specifically states myscript.jsp. Now I tried it out by removing the .jsp extension from the script attribute, and this seems to work! 
> So my question now is, is there a reason not to do it this way? Why is it stated in the docs that you should say myscript.jsp instead of just myscript, seeing as myscript alone already works too and would have made it possible to overwrite the specific scripts by other template engines.
> 
> Greetings,
> Roy
> 
> [1] https://sling.apache.org/documentation/bundles/scripting/scripting-jsp.html#call <https://sling.apache.org/documentation/bundles/scripting/scripting-jsp.html#call>