Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6097321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:01:48+00:00 2026-05-23T13:01:48+00:00

I use Java and call a webservice. When I display the response on my

  • 0

I use Java and call a webservice. When I display the response on my web page with :

String str=answer.toString();
label.setText(str);

It’s okay. But when I want to call a JavaScript function, I fail. I used a code which worked ( here ) and changed it to do what I want.
So in the beginning of my code I have

import netscape.javascript.JSException;
import netscape.javascript.JSObject;

then later

        try {
        jso = JSObject.getWindow(this);  // line 38
    } catch (JSException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

then later

jso.call("affiche1",new String[] {String.valueOf(str.trim()).trim()}); // line 110

“affiche” is my js function which should display the answer on my web page.

When I run it with Eclipse I get the errors

netscape.javascript.JSException
at netscape.javascript.JSObject.getWindow(Unknown Source)
at Test2.init(Test2.java:38)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

java.lang.NullPointerException
at Test2$1.actionPerformed(Test2.java:110)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

The lines 38 and 110 are precised above.
When I run it in Mozilla, I get the errors

XML or text declaration not at start of entity Line 1

  "<html xmlns="http://www.w3.org/1999/xh...teReply></soap:Body></soap:Envelope></"

and

An invalid or illegal string was specified” code: “12
file:///L:/pwe/onload_refresh/ngonl/pub/htmlkit/effects.js
Line 22

I have not found something similar on the web. I just found advices : to drop the whitespace in my xml file, but I think it is not that because there is no problem when I display it inside the applet (and I don’t know exactly how doing that, I am a very beginner in java).

I really don’t understand because I have the line

jso.call("affiche1",new String[] {String.valueOf(str.trim()).trim()});

I drop white spaces before and after with trim() – two are not necessary, but I wanted to be sure to drop it ! I think the errors in Eclipse are not important because I got the same with something which works (she may be here because it s calling javascript, and javasript is not in my eclipse project ?).

I find it very strange because I have a string, and not a XML, right ? So I really dont understand why this error is raised…

Thank you very much for any help and advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:01:48+00:00Added an answer on May 23, 2026 at 1:01 pm

    Problem solved :

    it was the innerHTML, because there were non-HTML tags inside.
    So, instead of doing directly a innerHTML, I call this function in javascript :

    function test (str) {
        function parseXML( xml ) {
            if( window.ActiveXObject && window.GetObject ) {
                var dom = new ActiveXObject( 'Microsoft.XMLDOM' );
                dom.loadXML( xml );
                return dom;
            }
            if( window.DOMParser )
                return new DOMParser().parseFromString( xml, 'text/xml' );
            throw new Error( 'No XML parser available' );
        }
    
        str = parseXML(str);
        var supertest = str.getElementsByTagName("tag1")[0].childNodes[0].nodeValue;
        document.getElementById('ici').innerHTML ="value of tag1  :  " + supertest;
    }
    

    I parse it (string to dom), then I get the value I want (into tag1 tag), then I edit the html. In fact, that is what I wanted. Testing to display the entire string was not a good idea, and couldnt be done because of the < tag > inside.

    Hope it will help someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to test a Java Service Call. My first attempt was to use
I have a java web app that makes back-end use of a third-party web
I can use (.toUpperCase GOOD) in clojure, as GOOD is java string, and java
I get this error when I use my autogenerated ServiceBindingStub.java. WebService side is working
I am using a java applet to call Web Services. This java applet is
I want to read a response from a non-wsdl web service call using JAXB.
Help! I'm getting this error when trying to connect using JAX-WS webservice call: java.lang.NoClassDefFoundError:
I have a web services written in java using jersey framework when i call
I'm trying to call a web service in my back end java code when
from .NET 3.5 C# web application we want to connect to Java WebService. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.