You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Sandro Boehme <sa...@gmx.de> on 2014/08/08 10:40:29 UTC

modify a mounted JSP / FSResource from a servlet

Hi,

to work with a JSP in Sling I mounted it to the Sling resource tree 
using "<Sling-Initial-Content>", "<mountByFS>true</mountByFS>" and so on 
in the pom.xml [1].
Now I would like to modify that JSP [2] using a servlet [3].
The servlet gets called and there I can modify the JSP content by 
changing and saving the corresponding node.
But the change doesn't end up in the JSP. Do I use the right approach?
I only found one [4] documentation about that. Is there more that I 
haven't seen yet?

One reason might be, that I use
`Resource contentResource = resource.getChild("jcr:content");`
in PUT.java:72 to get the resource and do the subsequent change because
´resource.adaptTo(Node.class);´ in line 75 returns null.

Does somebody have an idea on how to change the JSP using the servlet?

Any hint is appreciated!

Best,

Sandro


[1] - 
https://github.com/sandroboehme/jcrbrowser/blob/master/jcrbrowser/pom.xml

[2] - 
https://github.com/sandroboehme/jcrbrowser/blob/master/jcrbrowser/src/main/resources/SLING-INF/libs/sling/servlet/default/jcrbrowser/dhtml.jsp

[3] - 
https://github.com/sandroboehme/jcrbrowser/blob/master/jcrbrowser/src/main/java/org/sboehme/jcrbrowser/PUT.java

[4] - 
http://sling.apache.org/documentation/bundles/accessing-filesystem-resources-extensions-fsresource.html

Re: modify a mounted JSP / FSResource from a servlet

Posted by Sandro Boehme <sa...@gmx.de>.
Thanks a lot for your quick answer Carsten! It was very helpful.

Best,

Sandro

Am 08.08.14 10:45, schrieb Carsten Ziegeler:
> Hi,
>
> the file resource provider which mounts the JSP does not handle changes,
> it's right now read only. Therefore if you want to do something like this,
> you either need to implement Create/update for the provider or directly
> modify the file on the file system
>
> Carsten
>
>
> 2014-08-08 10:40 GMT+02:00 Sandro Boehme <sa...@gmx.de>:
>
>> Hi,
>>
>> to work with a JSP in Sling I mounted it to the Sling resource tree using
>> "<Sling-Initial-Content>", "<mountByFS>true</mountByFS>" and so on in the
>> pom.xml [1].
>> Now I would like to modify that JSP [2] using a servlet [3].
>> The servlet gets called and there I can modify the JSP content by changing
>> and saving the corresponding node.
>> But the change doesn't end up in the JSP. Do I use the right approach?
>> I only found one [4] documentation about that. Is there more that I
>> haven't seen yet?
>>
>> One reason might be, that I use
>> `Resource contentResource = resource.getChild("jcr:content");`
>> in PUT.java:72 to get the resource and do the subsequent change because
>> ´resource.adaptTo(Node.class);´ in line 75 returns null.
>>
>> Does somebody have an idea on how to change the JSP using the servlet?
>>
>> Any hint is appreciated!
>>
>> Best,
>>
>> Sandro
>>
>>
>> [1] - https://github.com/sandroboehme/jcrbrowser/blob/
>> master/jcrbrowser/pom.xml
>>
>> [2] - https://github.com/sandroboehme/jcrbrowser/blob/
>> master/jcrbrowser/src/main/resources/SLING-INF/libs/sling/servlet/default/
>> jcrbrowser/dhtml.jsp
>>
>> [3] - https://github.com/sandroboehme/jcrbrowser/blob/
>> master/jcrbrowser/src/main/java/org/sboehme/jcrbrowser/PUT.java
>>
>> [4] - http://sling.apache.org/documentation/bundles/accessing-filesystem-
>> resources-extensions-fsresource.html
>>
>
>
>


Re: modify a mounted JSP / FSResource from a servlet

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

the file resource provider which mounts the JSP does not handle changes,
it's right now read only. Therefore if you want to do something like this,
you either need to implement Create/update for the provider or directly
modify the file on the file system

Carsten


2014-08-08 10:40 GMT+02:00 Sandro Boehme <sa...@gmx.de>:

> Hi,
>
> to work with a JSP in Sling I mounted it to the Sling resource tree using
> "<Sling-Initial-Content>", "<mountByFS>true</mountByFS>" and so on in the
> pom.xml [1].
> Now I would like to modify that JSP [2] using a servlet [3].
> The servlet gets called and there I can modify the JSP content by changing
> and saving the corresponding node.
> But the change doesn't end up in the JSP. Do I use the right approach?
> I only found one [4] documentation about that. Is there more that I
> haven't seen yet?
>
> One reason might be, that I use
> `Resource contentResource = resource.getChild("jcr:content");`
> in PUT.java:72 to get the resource and do the subsequent change because
> ´resource.adaptTo(Node.class);´ in line 75 returns null.
>
> Does somebody have an idea on how to change the JSP using the servlet?
>
> Any hint is appreciated!
>
> Best,
>
> Sandro
>
>
> [1] - https://github.com/sandroboehme/jcrbrowser/blob/
> master/jcrbrowser/pom.xml
>
> [2] - https://github.com/sandroboehme/jcrbrowser/blob/
> master/jcrbrowser/src/main/resources/SLING-INF/libs/sling/servlet/default/
> jcrbrowser/dhtml.jsp
>
> [3] - https://github.com/sandroboehme/jcrbrowser/blob/
> master/jcrbrowser/src/main/java/org/sboehme/jcrbrowser/PUT.java
>
> [4] - http://sling.apache.org/documentation/bundles/accessing-filesystem-
> resources-extensions-fsresource.html
>



-- 
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org