1

I'm writing a CouchDB sample. My intention is to write a web app using AJAX and deploy it in the tomcat environment. As I use the CouchDB I would like to know the way to interact with the CouchDB server. However there were few examples but I have few concerns over that.

1) As my application is deployed in a web server is it possible to connect with a CouchDB outside? Many examples uses apps which are deployed in CouchApp or Couch environment itself.

2) If so will it end up with cross domain issues. I found this in here

Connection AJAX, CouchDB and JavaScript

However will this be a problem? Is this the correct way to achieve this?

3) To omit above issues is it possible to use some server side javascript implementation as an example Rhino?

http://www.mozilla.org/rhino/doc.html

4) If I use Rhino above it wont allow many java script libraries to use. How do I interact with CouchDB then? Do I have to invoke native Javascript? Cant I use something like JQuery?

5) What are the best libraries for client side to achieve my goal?

Your help is appreciated.

Thank you

Community
  • 1
  • 1
Dilshan
  • 3,231
  • 4
  • 39
  • 50
  • Is there a reason you are going to run the webapp in tomcat (or another java container)? Unless there is a real need you might want to ditch it, and go with just a couchapp. – Ryan Ramage Jan 11 '12 at 15:38
  • Yes I have existing frameworks developed in JavaEE so needs to run that in a tomcat container. So its a must for me. – Dilshan Jan 11 '12 at 16:46

1 Answers1

1

Based on your need to use tomcat, I would just recommend using ektorp (http://ektorp.org/). Just think of ektorp like a jdbc driver. No need to do ajax from the user interface, or no need to use javascript from java in your server.

Ektorp also lets you annotate your java classes with the javascript couchdb needs to make views. see the example here: http://ektorp.org/reference_documentation.html#d100e753

Hope that helps.

Ryan Ramage
  • 2,606
  • 18
  • 17
  • Thanks it helps. But I am working on server side javascript (Rhino). Its hard to use them inside that. – Dilshan Jan 11 '12 at 17:24
  • Hmm, in serverside rhino you can expose java objects, cant you? Why not configure an ektorp db object and stick it in the context? Otherwise, you might have to just do http calls from rhino. – Ryan Ramage Jan 11 '12 at 17:46
  • Ya seems like can do. But I'm keen on doing that in AJAX. Later I'm planing to move to PhoneGap so the AJAX approach will be a useful for it. – Dilshan Jan 11 '12 at 17:50