Redirect to referer and show error

Hello,

I work on a plugin using filter servlet Filter trigger by :

  • pages/attachfile.action
  • pages/doattachfile.action*
  • pages/plugins/attachments/doattachfile.action*
  • /plugins/drag-and-drop/upload.action*

So when I have a functionnal error using condition in doFilter method, I want to redirect to my referer URL and show a dialogMessage with my error.

How I can proceed ?

Version of Confluence : 8.5.4.

Regards,
Guillaume