You basically need to convert DOC(X) to HTML for editing and HTML to DOC(X) after saving. That's also what Google Docs is basically doing.
Your next question shall most probably be, "How do I convert from DOC(X) to HTML and back?". You can use among others Open Office API for this, or a library on top of it like JDOCConverter. Alternatively, you can also parse the DOC(X) yourself with help of a low level API like Apache POI HWPF and then generate the desired HTML accordingly based on the infomation collected in Java objects.
No, this is not a trivial task. You need to have a good understanding of the DOC(X) format (this question alone already shows that you don't have) and the limitations during the conversion step. I'd personally recommend to just use Google Docs.