WebApp Response Message

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

WebApp Response Message

Post by Konstantin »

Hello !!!
I use WebApp 18.0.0
I made Save for documents (I use servlet for saving on custom datesource site) and now I need handle different error messages.
When I spend:

Code: Select all


protected void doPut(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
resp.sendError(404, "Error message");
}
I get message:
Error saving document: 404 Not Found for: http://localhost:8888/webapp_editor?sou ... tId=111111
How can I show my messages in webapp ?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: WebApp Response Message

Post by cristi_talau »

Hello,

To be sure I understand your context: you are using oXygen XML Web Author 18.0.0 (as part of the SDK) and using the "http" or "webdav" protocol to load and save document. Right?

In Web Author we currently ignore the server response on HTTP requests since sometimes it contains an entire HTML page that is not suitable to display in an error message. I registered an improvement request to display the server response if it is plain-text or just contain inline markup link <a> or <b>.

If that turns out to be a showstopper for you, we can try to find a workaround until the fix is released.

Best,
Cristian
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: WebApp Response Message

Post by Konstantin »

To be sure I understand your context: you are using oXygen XML Web Author 18.0.0 (as part of the SDK) and using the "http" or "webdav" protocol to load and save document. Right?
You right, we use http protocol.
We need use custom messages in response.
Could you help ?
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: WebApp Response Message

Post by cristi_talau »

We are going to make this change in the next version of oXygen XML Web Author.

If you want this functionality in 18.0 you will need to patch our WebDAV plugin available on GitHub [1] and install it in Web Author [2]. You will have to use webdav-http instead of http when passing the URL to the Web Author.

Basically you should insert a code snippet like below in the WebdavUrlConnection class [3].

Code: Select all


if (this.delegateConnection instanceof HttpURLConnection) {
InputStream is = ((HttpURLConnection)this.delegateConnection).getErrorStream();
String message = null;
try {
message = IOUtils.toString(is, "UTF-8");
} catch (IOException e) {
} finally {
IOUtils.closeQuietly(is);
}
if (message != null) {
throw new IOException(message, e);
}
}
Best,
Cristian

[1] https://github.com/oxygenxml/webapp-webdav-integration
[2] https://www.oxygenxml.com/doc/versions/ ... ugins.html
[3] https://github.com/oxygenxml/webapp-web ... .java#L101
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: WebApp Response Message

Post by Konstantin »

Big thanks !
Post Reply