File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Java to provide file write features to Javascript to emulate DB activity

 
Scott Dinwiddie
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on creating a Java stub to give write access via Javascript calls. I only need write access to a single text file that will serve as my data repository. This is going to be used to teach database interactivity through Javascript without requiring an SQL server or using the new HTML5 local database. Thank you for any assistance/suggestions.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

What exactly is your question? Can you explain in more detail what exactly you're looking for?
 
Scott Dinwiddie
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript cannot write to localhost files (txt file in this case). I can get it to perform the write to file using ActiveX (got it working in IE currently), however, I am trying to figure out how to achieve this for Firefox/Chrome since they don't recognize ActiveX objects. I am taking the approach of creating a Java applet/whatever that can be called from javascript and passed the data to write to the .txt file creating a window for local file writing for Javascript to work through in Firefox and Chrome. I suppose my question would be, what would be the most effective way to provide file write capabilities to Javascript? I am looking at using what I refer to as a "Java Stub" to achieve this for Chrome and Firefox since I can use an ActiveX object to do it in IE. Thank you.

Edit: I am aware that applets are sandboxed via the JVM, however, it has occurred to me to attempt to call the applet from Javascript passing the data to be written to the applet, then calling a local jar file from the applet and relaying the data to the local jar file in hopes of stepping out of the sandbox for the applet.

The end goal is to emulate database access with Javascript without requiring a database server and keeping on the localhost for learning purposes.
 
Paul Clapham
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible for Javascript to call public methods in an applet which is loaded in the same page. And it is possible for the applet to update files on the local machine, if it is a signed applet.

However I have no idea what

calling a local jar file from the applet and relaying the data to the local jar file


means. A jar file is just a container for classes and other resources, so you can't "call" it and "relaying data" to it also doesn't make sense. At any rate, whatever you meant by that, it sounds a lot more cumbersome than just writing to a file.
 
Jayesh A Lalwani
Rancher
Pie
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whaa?? You are teaching peoplehow to make Javascript interact with a local database? Why? Who on earth does that?

 
Scott Dinwiddie
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll dig into the signed applets topic and take that approach. Thanks Paul.


It's not teaching people to use Javascript to access local databases. It's removing the database aspect and EMULATING database transactions. A JS API is what will access the text file that will serve as a data repository on the localhost side so those learning only have to worry about coding the JS side and make calls to the API to read/write data in the text file. Just a workaround to separate the database 'layer' in order to focus on the JS code for database access. It's a step for beginners to get a handle on coding JS without having to deal with the actual database transactions, which is in the next level of classes.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic