import javax.servlet.*; import javax.servlet.http.*; import com.softwareag.tamino.db.api.accessor.*; import com.softwareag.tamino.db.api.common.*; import com.softwareag.tamino.db.api.connection.*; import com.softwareag.tamino.db.api.objectModel.*; import com.softwareag.tamino.db.api.objectModel.dom.*; import com.softwareag.tamino.db.api.response.*; import org.jdom.*; import org.jdom.input.*; import java.io.*; public class test extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); // Put the XML content into a StringReader StringReader stringReader = new StringReader( XML ); // Instantiate an empty TXMLObject instance using the DOM object model TXMLObject xmlObject = TXMLObject.newInstance( TDOMObjectModel.getInstance() ); /* // Establish the DOM representation by reading the content from the // character input stream xmlObject.readFrom( stringReader ); // Establish the connection to Tamino TConnection connection = TConnectionFactory.getInstance().newConnection( DATABASE_URI ); // Obtain a TXMLObjectAccessor with a DOM object model TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor( TAccessLocation.newInstance( "ino:etc" ), TDOMObjectModel.getInstance() ); try { // Invoke the insert operation xmlObjectAccessor.insert( xmlObject ); // Show the ino:id of the document just inserted out.println( "Insert succeeded, ino:id=" + xmlObject.getId() ); } catch (TInsertException insertException) { // Inform about the reason for the failure out.println( "Insert failed!" ); if ( insertException.hasAccessFailureMessage() ) out.println( "Insert rejected by Tamino. Reason:" + insertException.getAccessFailureMessage() ); else out.println( "Insert failed due to following reason:" + insertException.getDeepestException().getMessage() ); } // Prepare to read the instance TQuery query = TQuery.newInstance( xmlObject.getDoctype() + "[@ino:id=" + xmlObject.getId() + "]" ); try { // Invoke the query operation TResponse res = xmlObjectAccessor.query( query ); if ( res.hasFirstXMLObject() ) { StringWriter stringWriter = new StringWriter(); res.getFirstXMLObject().writeTo( stringWriter ); out.println( "Retrieved following instance:" + stringWriter ); } else out.println( "No instance found!" ); } catch (TQueryException queryException) { // Inform about the reason for the failure out.println( "Query failed!" ); if ( queryException.hasAccessFailureMessage() ) out.println( "Query rejected by Tamino. Reason:" + queryException.getAccessFailureMessage() ); else out.println( "Insert failed due to following reason:" + queryException.getDeepestException().getMessage() ); } // OK, everything is done, close the connection. connection.close();*/ } // URI of the Tamino database, please edit accordingly public final static String DATABASE_URI = "http://localhost/tamino/myDB"; // XML document to be written to the connected database public final static String XML = "Hello World"; }