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 ?
Solved! Go to Solution.
Views
Replies
Total Likes
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
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
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
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
Hi @krishna_chaita2 ,
To avoid download we need to set header at dispatcher level, Content disposition filter is not supported in AEMaaCS.
<LocationMatch "^/content/dam/.*\.(?i:html)$">
Header unset "Content-Disposition"
Header set Content-Disposition inline
</LocationMatch>
Thanks
Hi @krishna_chaita2 try the solution from @MukeshYadav_as it is better and simpler to manipulate headers in Dispatcher.
Good luck,
Daniel
Hi@daniel-strmecki @MukeshYadav_ ,
Issue resolved on moving static htmls to /etc/statichtmls folder. Thanks you so much for the inputs.
Thanks
K Chaitanya
Views
Likes
Replies
Views
Likes
Replies