Expand my Community achievements bar.

How can we customize invalid POST servlet Response

Avatar

Level 2

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>

7 Replies

Avatar

Community Advisor

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-errorh...

 

 

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

 

Regards,

Rajashankar

 

Avatar

Level 2

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).

Avatar

Community Advisor

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

Avatar

Level 2

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

Avatar

Community Advisor

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



Arun Patidar

Avatar

Level 2

We are not able to achieve by overlaying /libs/sling/servlet/errorhandler/default.jsp without modifying the "default servlet" as we are trying to update the invalid servlet response. So we are not trying find a way to update the above posted HTML(response).