1

I'm new to Java Web Services and I'm trying to write a method in my JSP page that would edit a database entry based on an id that is provided by clicking a button. However, I seem to be unable to use the method argument for the id as the JAX-WS code does not recognize the variable (I get the "cannot find symbol" error message in NetBeans). How do I access the id in the JAX-WS code?

Any help would be much appreciated!

Thank you in advance

Method call: <button onclick=\"editWS(" + id +")\">Edit</button>

EditWS(id) call/JAX-WS code in the JSP:

function editWS(id) {
    <%-- start web service invocation --%>
    <%
    try {
        
       proj.beans.service_client.MessageWS_Service service = new 
       proj.beans.service_client.MessageWS_Service();
       proj.beans.service_client.MessageWS port = service.getMessageWSPort();
       // TODO initialize WS operation arguments here
       proj.beans.service_client.Message entity = port.find(id); //Error: cannot find symbol 'id'
       port.edit(entity);
    } catch (Exception ex) {
       // TODO handle custom exceptions here
    }
    %>
    <%-- end web service invocation --%>

    }
eee
  • 37
  • 2
  • 6
  • You are using `js` inside java code ? – Swati Oct 20 '20 at 13:06
  • @Swati The code that creates the button is in JS and I'm struggling to figure out how to make it work with the Java code of the Web Service :( – eee Oct 20 '20 at 18:19
  • Hi ,you cannot pass that way as js is client-side and jsp is server-side.. I would suggest you using `ajax` or `form` . And i am not sure this way would work but [this](https://stackoverflow.com/a/5701347/10606400) might help. – Swati Oct 21 '20 at 03:48

0 Answers0