JWS Application to Browser (JavaScript) communication

Here is my scenario:
I would like to use Java Web Start technology to distribute a training simulation application. The main application is written in native code, and I would like to launch the app from a web browser, and have the native app send simple messages back to the browser (i.e. "Objective xyz completed").
So far I've been able to create a Java Web Start wrapper application and deploy it along with the native code and resources via Java Web Start. So far so good. I also have tackled JNI to enable the native app to talk to the JWS wrapper.
My problem is getting the Java app (started via JWS) to talk back to the browser (specifically a JavaScript method or headless Java applet). Do my dismay, I have found that there is no direct way for JWS app to talk to the browser that launched it. So what are my "indirect" options?
I have been toying with the following ideas:
1) use a java applet in the browser to talk with the JWS app via sockets
2) use a java applet in the browser to talk with the JWS app via RMI
Is my analysis correct, or are there any other possible solutions to my problem?
Note that I am already using native code in the JWS app, so I will have to have some sort of elevated permissions anyway...
Thanks,
Chris

Sorry, but one of the main differences between an Applet and a JNLP app is that JNLP apps don't know anything about the browser. (The browser only knows about the JNLP MIME-type, which is (hopefully) associated with JavaWS.)
Basically, think of the JNLP app as any other stand-alone app when it comes to the browser. If you need to talk to the browser, then anything that would let a stand-alone app talk to the browser will also work for a JNLP app. However, I don't know of any standard tactic for doing this.
One question is, do you really need to talk to the browser, or is it possible you just want to talk to your server using HTTP?
Also, if all you want the browser to do is display a specific page, then there is an API for that in 5.0. This is described here:
        http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/examples.html#BasicService
If you really need to talk to the browser, then you should probably consider writing your application as an applet instead.
Mike.

Similar Messages

  • Using browser javascript to copy selected text from a pdf file opened in Air app.

    I have posted this question on reader forum as well, but I think it is more suited here...
    I am trying to create a note-taking application in air. I want to extract selected text from pdf file as a string object or to the clipboard.
    Obviously, all pdfs in my local storage will not be scripted to recieve postMessages and act accordingly, and that is not practical either. So, my problem is, how can I copy the selected text in the pdf file (opened as an object in htmlloader within my Air app) to clipboard or directly in another control by say clicking a button in air application? I suppose, this is possible using javascript, however, I don't know which reader methods are exposed to the wrapper htmlloader control. In short, I want to execute app.execMenuItem("Copy") command through htmlloader javascript. Any alternate solutions are also welcome.
    This is similar to passing inbuilt commands/methods/functions (of adobe reader) to pdf-reader plugin embedded in a webpage via javascript. This is possible in IE where the pdf is rendered as activex object, and hence JSObject interface of pdf document/reader is accessible to the browser javascript. I have also read that this same JSObject is accessible to VB as interface for IAC, so as the Air is Adobe's own product, I was wondering if equivalent of JSObject is accessible to htmlloader control as well.
    Thanks in advance...
    Mits

    Thank you Thom for your reply...
    from
    http://www.adobe.com/devnet/acrobat/javascript.html
    ...Through JavaScript extensions, the viewer application and its plug-ins expose much of their functionality to document authors, form designers, and plug-in developers...
    As it is explicitly mentioned, that the functionality of adobe reader are exposed for plugin development, I thought someone here might have used external javascript to execute some safe methods in adobe reader. The functionality (i.e. external javascript interface-JSObject) is already available for VB programmers to develop IAC. Further, the Acrobat SDK example called "AcroPDFinHML" shows how one can embed a pdf-reader in a html page and execute some safe methods (like gotonextpage(), zooming etc.) in IE as ActiveX plugin. I have checked it myself for adobe reader 9, and it works perfectly, so there is no security issue as such to implement the same for another browser (like in my case, the htmlloader control in flex/air app).
    I intend to create a note taking application in air, where it is very much required that I should be able to copy selected text from various pdf documents, that are open in my app, and subsequently paste/collect/save the collected notes and process them afterwords (offcourse, from the pdfs that allow me copying text). However, it is not happening for me here. As the pdfs are opened through adobe reader plugin, it does not register the copy command executed by my air app. It registers the system level copy command (by keyboard shortcut Ctrl+C), but my air app has no way to execute the system level copy command programmatically. So I am kind of stuck here...
    Thanks again for your reply. Having known what am I intend to accomplish, any other (may be alternative) solutions will be appreciated nonetheless...
    Mits

  • Applet javascript communication

    hi all,
    I want my applet to flash the browser window, came to know that can be done
    using applet javascript communication.
    ne1 has ne idea how to do that.
    thx in adv,
    kiran

    ???

  • Launch All Web Applications in browser using PowerShell

    Hi Admins,
    I am working on a Script where I should be able to launch all the web applications in the browser to open in tabs.
    I have worked out with the following script and was able to come upto an extent where I am able to launch the Internet Explorer.But ....only 1 web app opens up and throws an error message :
    Exception calling "Navigate" with "1" argument(s): "The interface is unknown. (Exception from HRESULT: 0x800706B5)"
    Below is my script
    Add-PSSnapin Microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
    $webApps = Get-SpWebapplication
    foreach($webapp in $WebApps){
    $URL = $webapp.URL
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate($URL)
    while ($ie.busy -eq $true) {
    Start-Sleep -Milliseconds 600
    $ie.Visible = $true
    Can anyone help me know where I am making the mistake ?
    Regards

    Hi,
    As I understand, you want to lunch all web applications in browser using PowerShell.
    I can achieve it by the PowerShell code below:
    foreach($webapp in $WebApps){
    $ie = New-Object -ComObject InternetExplorer.Application
    $URL = $webapp.URL
    $ie.Navigate($URL)
    $ie.Visible = $true
    You can try it and check it if can work.
    For the error message, I recommend to run the SharePoint Management Shell as administrator or turn off User Access Control and then check how it works.
    Best regards
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]
    The above code will open 3 different browser. OP requested to launch all web application in different tabs. To achieve this we need to use the code below
    $webApps = Get-SpWebapplication
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.Navigate($webApps[0].URL)
    for($i=1; $i -le $WebApps.length-1; $i++)
    $ie.Navigate2($WebApps[$i].URL,0x10000)
    $ie.Visible = $true
    Regards Chen V [MCTS SharePoint 2010]

  • Browser Javascript call Acrobat Javascript function

    What I want to do is call a function in Acrobat Javascript by clicking a button in my browser.
    So if you click the browser button it executes a javascript function that calls an acrobat javascript function.
    I found this example:
    Browser javascript
    function printDocument() {
         var pdfObject = document.getElementById(\"PDFObj\");
         pdfObject.postMessage([\"alert\", \"Hello from HTML\"]);
    Acrobat javascript
    In the secure folder (C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Javascripts\kassa.js) my folder level script
    so this is executed for each pdf document.
    this.hostContainer.messageHandler =
         onMessage: function(aMessage)
              for(var i = 0; i < aMessage.length; i++)
              console.println("Recvd Msg[ " + i + "]: " + aMessage[i]);
          onError: function(error, aMessage){ },
          onDisclose: HostContainerDisclosurePolicy.SameOriginPolicy
    This should do the job...
    But if i look at the javascript debugger window(acrobat)
    it shows:
    this.hostContainer has no properties
    9:Folder-Level:App:kassa.js
    this.hostContainer has no properties
    9:Folder-Level:App:kassa.js
    Any solution for my problem?

    hi levi,
    Thank u very much for responding,
    to be precise i have to show the user a small window saying that the excel sheet is being prepared and once the sheet is prepared this window has to be closed. So to open and close this child window i need to use the javascript functions.
    currently my jsp looks this way
    <script>
         function open()
         funciton close()
    </script>
    <body>
    <script>
         open();
    </script>
    include x.jsp //sets the content type to excel
    include y.jsp //writes to the excel sheet
    <script>
         close();
    </script>
    <body>
    My x.jsp looks this way
    response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "filename=" + "abc.xls");
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Pragma","no-cache");
    response.setDateHeader("Expires",0);
    response.addHeader("Cache-control", "no-store");
    response.addHeader("Cache-control", "max-age=0");
    The issue is the javascripts are not getting called at all. Is there any other way to solve this. Since i am the beginner in this field i dont have much idea about this. A code snippet will be of great help.
    Thanx

  • Embedding JWS app in browser

    Hi,
    How can I run JWS applications from within a browser? I want to use JWS for downloading jars and showing a progress bar during the downloads, but I still want the applet to be embedded in the browser.
    Any help will be appreciated.
    Jas

    Hi,
    Thanks for your help. I was initially using java plug-in, but couldn't get indexing to work. JNLP gives a convenient way of specifying when to download jar files (eager or lazy).
    Any help on how to launch applet embedded in web browser with web start or jar file indexing will be appreciated.
    Jas

  • Setting application items through javascript

    Is there any way to modify application items using javascript? I would work with page items, but I need something that is guaranteed to be in the session state.

    Oh yes, I know that. Well here's the exact problem (I've posted threads on it from a couple different angles previously):
    - I am trying to open a popup with a report region such that I can send a query to the popup some how, without doing a page submission of the parent page.
    - The current method I am using is to send the query by URL, but I'm reaching the limit of URL length, and it's not a particularly secure solution.
    - My latest idea was to pass-by-reference (what this thread is about), but this presented a couple of problems.
    1) I could set a parent page item dynamically by JS, but the only way I know of loading the information automatically in the popup is using onLoad -- but that's too late.
    2) I could use session state, but I risk Region condition: javascript is enabled?, page session items are not set until a page is submitted, and application session items are not accessible by JS.
    I was thinking that maybe there is some way of accessing browser session state with JS, but I guess not....

  • Updating Applet in chat application in browser

    iam developing a chat application in browser using
    1.Http connection and no sockets
    2.Using applet iam sending messages to servlet in server and servlet handles the client request
    My problem
    how to update every clients connected to the server.
    (ie i want to pump the data that is recieved from one client to every one)

    If no socket connections is totally necessary then you could accomplish this task with this process using javascript as well as java.
    1. In your html web page that will contain the chat window. Create an html "Form" set the "Name" attribute for it. The chat window will be of input type "TEXTAREA" it will also have to have a "NAME" attribute set for it. Next create a new "Form" set the "Name" attribute.
    In the same new form add another input type of "TEXTFIELD" set the "Name" attribute and the "MAXSIZE" attribute if you want to limit the number of letters the text field will accept. Next in the same form add another input type of "SUBMIT" and add
    your servlet as an attribute.
    2. Construct your servlet in a manner that will receive
    the forms text field data by accessing "getParamater"
    method also create a "Cookie" object. As requests are sent to the servlet append the new text to the cookie object and send the new web page with the old cookie
    out to all sessions.
    3. Set the refresh time for your web page with the chat
    window to a reasonable amount of time.
    4. Add javascript to the web page. In the BODY tag of the html page add the javascript function onLoad="someFunction()". You will also have to add
    someFunction to the HEAD tag of the web page
    by doing something like this.
    <HEAD>
    <SCRIPT Language="javascript">
    function someFunction() {
    document.forms.<form name>.<text area name>.setText(document.cookie.cookieName.getValue())
    </SCRIPT>
    </HEAD>
    There may be some inconsistencies in these instructions,
    but its functionality is sound. Good luck.

  • Decompile / reverse engineer JWS applications?

    If a program is deployed as a JWS application does that allow a user to decompile / reverse engineer the application code that is stored on the user's computer (assuming ineffective obfuscation)?
    If that is true then is it not better to continue to deploy the program as an applet so that the user can not access the applet code?
    (I apologise if this is a trivial question but I couldn't find this issue being addressed in any of the JWS hype)
    Cheers

    If a program is deployed as a JWS application does
    that allow a user to decompile / reverse engineer the
    application code that is stored on the user's computer
    (assuming ineffective obfuscation)?Yes, of course.
    If that is true then is it not better to continue to
    deploy the program as an applet so that the user can
    not access the applet code?No, that's a false assumption. If the class bytes are accessible via a web browser (how else can the applet work?) then they can be saved to the local machine and reverse-engineered.
    If you want to increase the difficulty of reverse-engineering you should use an obfuscator. Just make sure it's a good one that produces class bytes that pass the verifier.

  • Signed applet and javascript communication

    Hi All,
    I have an (jar) signed applet which I use to access system properties (e.g user.home). I also have a javascript code that communicates (call to a public function) with the applet to get the property "user.home" from the applet. Everything works fine in Java plugin 1.3 but since I have installed the latest plugin 1.4.2_01 from http://www.java.com/en/download/windows_automatic.jsp website I can not access the system properties even though everything in the code is same.
    I can however still access public functions/variables from the same applet which do not access system properties in the new plugin 1.4.2_01.
    The browser I am using is IE and OS is Windows 2000.
    Does anybody know if Sun has changed the security policy for 1.4.2_01, in the new plugin for java-javascript communication to block access to functions which uses system property,fileIO, socket etc. even if they are signed applet??
    Thanks in advance..

    When invokin applet methods via javascript, you are accessing privileged actions from an unsafe source.
    Depending on your needs, you could either load the system variables in applet init into class variables and return the information contained in the class variables to javascript or wrap the method calls inside AccessController.doPrivileged() calls.

  • How to share the same session between JNLP Application and browser session

    How to share the same session between JNLP Application and browser session using BasicService.showDocument(url) method? It appears whenever i launch any URL from within a JNLP application using BasicService.showDocument(url) , it creates new instance of browser and session even after i used cooke handlers to restore JSESSIONID and Ltpa token etc.
    public static int showDocument(String urlToOpen)
    BasicService obj = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
    obj.showDocument(urlToOpen);
    }

    Try using Reflection

  • Transfer Data from a JWS-Application to another one

    Hello
    I have an JWS-Application that starts another JWS-Appliction via BasicService, showDocument(...).
    Is there a way to transfer a large amount of data from the first application to the second one without using the filesystem?
    Thanks.

    >
    Nice demo Andrew.>Thanks. If anybody has the time, they might try adjusting the source file for that, from 16,000 bytes and see if they can claim the Meg. memory.
    ..some minutes later.
    OK. It seems it can, so long as the user agrees (and it has not been barred by the system admin. etc.). First I got a dialog saying.
    The maximum size of allotted storage is 262,144 bytes. 
    The applications has requested to increase it to
    15,000,000 bytes.But once I'd OK'd it, then the console output read:
    Cache created - size: 15000000Edit 1:
    Alternately, to keep it both entirely sandboxed and without prompts. Request only the 262,144 (80Kb by my calculations) and write the data part by part within that limit.
    The reading app. would need to check the persistence cache on a Timer (or similar) while the writing app. in turn checks it regularly during write operations. As soon as the reading app. has noticed and read the latest chunk of data, it sets a flag in the persistence service, and the writing app. writes the next chunk.
    Edited by: AndrewThompson64 on Dec 9, 2008 9:30 PM

  • How to access the value of application item in javascript

    How to access the value of application item in javascript?

    Hi,
    One way
    var myVariable = '&MY_APP_ITEM.';Br,Jari

  • Using value of application item in javascript

    Hello All,
    Apex 3.1
    I have a javascript that calls an application process, please see below. In the application process I have logic to set/change the value of an application item. Later in the javascript I need to set a page item to the value of the application item which was set in the application process. Any alerts that I post during the javascript show this value as blank, even though a similar HTP.prn in the application process displays the value!. After the script completes the correct value of the application item is in session state . Can someone explain this timing issue to me? Why can't I get the value of an application item in the javascript when the application process is called from the javascript?
    Is there a simple workaround here for me to get this value?
    <script>
    function f_ValidateLinkLine(pThis) {
       // The row in the table
       var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
       // is Link Line really a number? 
       if ( isNaN(html_GetElement('f20_'+vRow).value)) {
            if (html_GetElement('f20_'+vRow).value.length > 0) {
            alert('Link Line is an invalid number - '+html_GetElement('f20_'+vRow).value);
            html_GetElement('f20_'+vRow).value = '';
       } else { 
           if ( ! isNaN( parseFloat(html_GetElement('f20_'+vRow).value) ) ) {
       var link_line = parseInt(html_GetElement('f20_'+vRow).value);
       if (html_GetElement('f20_'+vRow).value.length > 0) {
          var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=ValidateLinkLine',0);
          get.add('F101_LINK_LINE',html_GetElement('f20_'+vRow).value);
          get.add('F101_INVENTORY_ITEM_ID',html_GetElement('inventory_item_id_'+Number(link_line)).value);
          get.add('F101_QUOTE_LINE_LINK_ID',html_GetElement('f01_'+spacer+link_line).value);
          get.add('F101_QUOTE_LINE_ID',html_GetElement('f01_'+vRow).value);
          get.add('F101_QUOTE_NUMBER',html_GetElement('f19_'+vRow).value);
          gReturn = get.get();
       // The application process can sometimes change the value of F101_QUOTE_LINE_ID
      //  and I need to set f37 to this value when this happens
        html_GetElement('f37_'+vRow).value =('&F101_QUOTE_LINE_ID.');  //< -- This does not work, the applicaiton item is blank!
          if (gReturn) {
           alert(gReturn);
          if(gReturn) {
           html_GetElement('f20_'+vRow).value = '';
           html_GetElement('f37_'+vRow).value = '';
       }  //End Check Length
      } else {
      html_GetElement('f37_'+vRow).value = '';
      } // is Link Line a number?   
    } // End If  
    } // End ValidateLinkLine
    </script>Edited by: blue72TA on Aug 16, 2011 11:39 AM
    Edited by: blue72TA on Aug 16, 2011 11:41 AM
    Edited by: blue72TA on Aug 16, 2011 11:41 AM

    Hi,
    When you use application item in JavaScript like you do, string &F101_QUOTE_LINE_ID. is substituted by item value from session state.
    Changes to that item value when you call On Demand process do not affect to page.
    Lets take example,
    You app item F101_QUOTE_LINE_ID value is e.g. XX in session state.
    You run page and see page source it looks like this
    html_GetElement('f37_'+vRow).value =('XX');Kind you have hard code value to JavaScript.
    Nothing will change that unless you refresh page.
    You need return value from On Demand process.
    To set value code could look like then
    html_GetElement('f37_'+vRow).value = gReturn;Regards,
    Jari

  • GREAT cross browser javascript xml libriary

    Hello !
    This cross browser javascript xml libriary, will make work with XML much easier.
    I am working on client side javascript at my job, and had to handle some data in big xml files using advanced xpath and this is not problem when dealing with IE but when it comes to Firefox and Opera it become nightmare to finish this job.
    Then I decided to write module in javascript that can handle xml query using xpath:
    http://www.softxml.com/softxmllib/softxmllib.htm
    It supports all known browsers on windows.
    It's functions named same as Microsoft.XMLDOM
    loadXML,load,selectNodes but supported by all browsers
    If any one of you tired too writing javascript/xml for all browsers, then go and download this module!!!!
    Thanks

    But since the only way (or at least so I think) to pass a
    javascript variable to CF is via a javascript
    document.location.href redirect (and passing the variables via URL
    variables), I have the javascript in the first page redirect and
    send the variables to the coldfusion template that then digests the
    xml and does a database insert.
    You should just do a server-side redirect and avoid
    Javascript altogether. As a rule of thumb, one should use
    Javascript to manipulate data or presentation at the client end.

Maybe you are looking for

  • How to find the user that deleted a sapscript

    Hi Is there a way to find out who deleted a sapscript in our Production system. Thanks

  • What about the Brass and Woodwind instruments?

    There should be brass and woodwind instruments. Such as a saxophone, a clarinet, a flute, and a trumpet.

  • Why does a 2nd Firefox open when I click on a pinned tab?

    90% of the time, when I click on one of the 10 pinned tabs to open it, a 2nd Firefox window opens up with the tab I clicked on, thus removing it from the original Firefox page (now only 9 pinned tabs). In other words, I have to minimize the 2nd windo

  • ITunes-Can't Right Click-Copy Paste

    http://img246.imageshack.us/img246/5302/picture3jg0.png (Example of what I see) I have seen this error before on these forums (once-http://discussions.apple.com/thread.jspa?messageID=3307808&#3307808), although the original poster never replied, so I

  • How exactly does graph.performInference() work?

    So as far as I understand, if a rules index does not exist, calling this function will call a SEM_APIS.CREATE_ENTAILMENT using whatever info it gets from the attachment. I noticed however that when the rulebase specified by the attachment already exi