How can we customize invalid POST servlet Response | Community
Skip to main content
April 18, 2022

How can we customize invalid POST servlet Response

  • April 18, 2022
  • 3 replies
  • 1961 views

We would like to customize the POST servlet response in case of the invalid servlet response, how can we customize this? OOTB response for the invalid servlet (/bin/testpost/rest) is like


How can we customize invalid POST servlet Response

<html>

<head>
<title>Error while processing /bin/testpost/rest</title>
</head>

<body>
<h1>Error while processing /bin/testpost/rest</h1>
<table>
<tbody>
<tr>
<td>Status</td>
<td>
<div id="Status">500</div>
</td>
</tr>
<tr>
<td>Message</td>
<td>
<div id="Message">org.apache.sling.api.resource.PersistenceException: Unable to create node at
/bin/testpost</div>
</td>
</tr>
<tr>
<td>Location</td>
<td>/bin/testpost/rest</td>
</tr>
<tr>
<td>Parent Location</td>
<td>/bin/testpost</td>
</tr>
<tr>
<td>Path</td>
<td>
<div id="Path">/bin/testpost/rest</div>
</td>
</tr>
<tr>
<td>Referer</td>
<td><a href="http://localhost:4502/en_US/book/page-search.html"
id="Referer">http://localhost:4502/en_US/book/page-search.html</a></td>
</tr>
<tr>
<td>ChangeLog</td>
<td>
<div id="ChangeLog"></div>
</td>
</tr>
</tbody>
</table>
<p><a href="http://localhost:4502/en_US/book/page-search.html">Go Back</a></p>
<p>Modified Resource</p>
<p>Parent of Modified Resource</p>
</body>

</html>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Bhuwan_B
Community Advisor
Community Advisor
April 18, 2022
RajaShankar
Community Advisor
Community Advisor
April 18, 2022

Hi @aemdev9 

Default error handling for servlet is located under /libs/sling/servlet/errorhandler/ .You can override this in your custom app as per your requirement.

Please refer this link for more info:

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/customizing-errorhandler-pages.html?lang=en#

 

 

You can customize either default.jsp or 404.jsp as per youre requirement.

 

Regards,

Rajashankar

 

aemdev9Author
April 18, 2022

Thanks for your response. We have to customize 500.jsp,  it won't work unless we set HttpServletResponse.sendError(500) explicitly and for this we have customize the OOTB default servlet (as we are trying to update invalid servlet response).

arunpatidar
Community Advisor
Community Advisor
April 19, 2022

Hi,

where do you want to achieve this? On Author or Publish instance.

If you are looking at publishing, you can simply set error handler at apache https server for 500 error.

Arun Patidar
aemdev9Author
April 19, 2022

Thanks for your response @arunpatidar, we would like to customize both on author and publisher.

arunpatidar
Community Advisor
Community Advisor
April 19, 2022

I think it that case you have to overlay /libs/sling/servlet/errorhandler/default.jsp

Arun Patidar