Hi community !
I have a JSP file and an AEM page, how do i make that JSP file to display my AEM page?
I can't find anything related to, it's that even possible ?
Edited: I'm also thinking at an internal redirect. This should also work for my purpose.
Thanks
Solved! Go to Solution.
So, I've used this in my 404.jsp and I achieved what i wanted
<%@include file="/libs/foundation/global.jsp"%>
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><sling:defineObjects /><%
response.setStatus(404);
request.getRequestDispatcher("/content/demo/somepage.html").forward(request,response); %>
Views
Replies
Total Likes
Hi,
What are you using for display AEM page JSP or HTL?
JSP - you can try below to include JSP in AEM Page
HTL - data-sly-include is to use include other html/jsp resources.
Thanks
Arun
Views
Replies
Total Likes
HI !
I have an JSP file and within this JSP file i want to display I page made in AEM which is found under /content/name-of-the-project/page-name
I have no clue how to bind them. I also thought about a redirect but my issue with is with the root path. How do i get the relative path ?
for now i'm using something like this
String redirectURL = "http://localhost:4502/content/demo/somepage.html";
but i want something like
String redirectURL = "/demo/somepage.html";
Views
Replies
Total Likes
I did not get your ask clearly. Please help us elaborate this.
-Kautuk
Views
Replies
Total Likes
Hi
Can you share some example, where is your JSP and where is your AEM page and why can't you use path from root?
or if you setup vanity URL to avoid /content/ is this feasible or not?
Please help us to replicate or implement.
Thanks
Arun
Views
Replies
Total Likes
So
I've overlayed the the script under the libs/sling/servlet/errorhandler/ so i can have my own custom 404 error script. And for that I want to use a page which I made on AEM.
So my JSP script is under /apps/sling/servlet/errorhandler/404.jsp and my page is under /content/demo/404
How can i bind them ?
That's what I'm willing to achieve
Views
Replies
Total Likes
So, I've used this in my 404.jsp and I achieved what i wanted
<%@include file="/libs/foundation/global.jsp"%>
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0" %><%
%><sling:defineObjects /><%
response.setStatus(404);
request.getRequestDispatcher("/content/demo/somepage.html").forward(request,response); %>
Views
Replies
Total Likes
Hi,
You can use HTL also for creating custom error pages functionality
for that you need to create 404.html and ResponseStatus.java inside /apps/sling/servlet/errorhandler
(You may create ResponseStatus.java outside repo and deployed as part of bundle)
Sample codes below :
404.HTML
<sly data-sly-use.responseStatus="apps.sling.servlet.errorhandler.ResponseStatus" />
<sly data-sly-resource="${'/content/AEM63App/en/page-not-found.html'}"></sly>
ResponseStatus.java
package apps.sling.servlet.errorhandler;
import com.adobe.cq.sightly.WCMUsePojo;
public class ResponseStatus extends WCMUsePojo {
@Override
public void activate() throws Exception {
getResponse().setStatus(404);
getResponse().setContentType("text/html");
}
}
Thanks
Arun
And please please, pay attention to the HTTP response statuscode! arunp99088702's example demonstrates how to do it right.
Jörg
Views
Replies
Total Likes
That's really helpful, thanks!!
But i can't really make it work with error 500.
I get this:
Status | 500 |
Message | org.apache.sling.api.SlingException: Exception during response processing. |
Location | /content/ui-centre/500.html |
Parent Location | /content/demo |
Path | /content/ui-centre/500.html |
Referer | http://localhost:4502/content/demo/page.html |
ChangeLog | <pre></pre> |
Go Back
Modified Resource
Parent of Modified Resource
Views
Replies
Total Likes
That's the error as displayed by the Sling Post Servlet. If you want to have proper error handling for them as well, at the moment it's not possible to handle both POST and GET the same way. See [1] for a way howto implement it.
Jörg
[1] [SLING-7552] SlingPostServlet error handling still insufficient - ASF JIRA
Views
Like
Replies