Send XML Response

Hi,

I would like to add functionality to my vaadin app which answers a xml request with a xml response. So no GUI at all, it 's for automatic processing of things, which an user can also use while working with gui.

My idea is to let my application implement HTTPServletListener, in method on onRequestStart I will get the writer with response.get PrintWriter and put my data there.

This works, but I get stacktrace in the log which complains, that getWriter was already called. I assume that after processing onRequestStart vaadin starts it’s own processing and something goes wrong then.

Is there another solution (besides deploying a separate servlet), so maybe stopping further processing in onRequestStart method?

Thanks, Rudolf

Would
URIHandler
work in your case? You’d need to get the posted data in the HttpServletListener, but perhaps the URIHandler would work better for returning the result?

See
this example
, which handles a bit similar case (if you leave the success part out…). If you’re a Pro Account subscriber, see
this article
for a short explanation of the code.

If the XML request handling is not linked to a specific Vaadin application instance, I think the simplest solution would be to have another (non-Vaadin) servlet in the same WAR that handles these. Then just map it to a suitable context path.

Thanks, I have chosen the servlet way and it works fine.