I am writing a Java application that requires access to a database, which is hosted on my (shared) web server. I do not need direct access to the database from the client side - and would prefer all database queries to take place on the server.
I have been looking at RMI (which is essentially what I'd like to achieve), but there doesn't seem to be a way to have a remote implementation on a Servlet.
My web server supports PHP, Servlets/JSP.
Is there a way to use RMI through servlets, would I be best implementing a Web Service or is there a better way of doing this?
If a Web Service is the better option, can this be done through servlets?
Thanks.
why would you want to use RMI? IMHO just use http if it will work for you. It's simpler. One popular approach is REST.
Basically they way it works is you map urls and parameters to server actions. For example, if you are loading people, you would stand up a people/
endpoint on your server. If you did an http GET on that endpoint, it would load people. If you did a POST it would create, and you do a PUT you update. Your server can read parameters and interpret them, for example if you passed an id
parameter on a GET request, you would load that specific person, not a list of people.
This approach requires some knowledge of the http protocol, but it's not that hard to learn and you should probably familiarize yourself with it anyway.