Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 26765
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic