users@grizzly.java.net

Can ErrorPageGenerator produce output other than HTML?

From: Henning Verbeek <hankipanky_at_gmail.com>
Date: Thu, 4 May 2017 12:20:22 +0200

Hello,

I'm using Grizzly within Jersey, purely as a REST endpoint. The server
consumes and produces content only with mediatype application/json.
For most errors, I can make this happen by registering Jersy
ExceptionMappers with Jersey: they produce a
javax.ws.rs.core.Response, where I can control the mediatype of the
entity.

Some errors don't make it Jersey though, instead grizzly uses the
configured default
org.glassfish.grizzly.http.server.ErrorPageGenerator. An example is
when an incoming request exceeds the configured maxPostSize.
Unfortunately, the ErrorPageGenerator#generate() method requires me to
generate a "HTML representation of the error page". I'd like to return
a response with mediatype application/json. Is that possible?

Thanks for your help.
Regards,
Henning