Expand my Community achievements bar.

SOLVED

AEM Author -- Static htmls Issue

Avatar

Level 4

We are adding some static htmls under /apps/statichtml/ folder . Browser is Properly rending those html's when we access these HTML's with AEM RDE Author environment Url -- <RDE_Author_hostname>/apps/statichtml/index.html. For Same HTMLs, Browser is showing direct html code when we open these with AEM as Cloud Dev Author environment Url -- <DEV_Auhtor_hostname>/apps/statichtml/index.html. When we check the response header's from Dev Author for these statichtml's "Content-Type" header is missing.
As suggestion on how to resolve this issue ?

1 Accepted Solution

Avatar

Correct answer by
Level 8

Hi @krishna_chaita2,

in that case, I think you will need to add some custom code and set the appropriate headers. This can be achieved with either a Filter or a Servlet. Maybe something like this:

@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) {
    final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
    final SlingHttpServletResponse slingHttpResponse = (SlingHttpServletResponse) response;
    if (this.isMyStaticHtmlPage(request) {
        slingHttpResponse.setHeader("content-type", "text/html");
    }
    filterChain.doFilter(request, response);
}

 

Hope it helps,

Daniel

View solution in original post

7 Replies

Avatar

Level 8

Hi @krishna_chaita2,

in case you want to avoid customizations in /apps, you can try to upload your static HTML page in /content/dam and remove the text/html mime type from DamContentDispositionFilter.

 

Hope this helps,

Daniel

 

 

Avatar

Level 4

Hi @daniel-strmecki ,

I tried on keeping html's in dam and updated DamContentDispositionFilter config. In this scenario, html file getting downloaded instead getting rendered.

Our requirement is to have html's in /apps folder only.

 

Thanks

K Chaitanya

Avatar

Correct answer by
Level 8

Hi @krishna_chaita2,

in that case, I think you will need to add some custom code and set the appropriate headers. This can be achieved with either a Filter or a Servlet. Maybe something like this:

@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) {
    final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
    final SlingHttpServletResponse slingHttpResponse = (SlingHttpServletResponse) response;
    if (this.isMyStaticHtmlPage(request) {
        slingHttpResponse.setHeader("content-type", "text/html");
    }
    filterChain.doFilter(request, response);
}

 

Hope it helps,

Daniel

Avatar

Community Advisor

Hi @krishna_chaita2 ,

To avoid download we need to set header at dispatcher level, Content disposition filter is not supported in AEMaaCS.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/content-disposition-on-aem...

<LocationMatch "^/content/dam/.*\.(?i:html)$">
Header unset "Content-Disposition"
Header set Content-Disposition inline
</LocationMatch>

Thanks

Avatar

Level 8

Hi @krishna_chaita2 try the solution from @MukeshYadav_as it is better and simpler to manipulate headers in Dispatcher.

 

Good luck,

Daniel

Avatar

Level 4

Hi@daniel-strmecki @MukeshYadav_ ,

 

Issue resolved on moving static htmls to /etc/statichtmls folder. Thanks you so much for the inputs.

 

Thanks

K Chaitanya