0

I have java class and I want to call it in my jsp page. My java class something like this

public static String imagesClass(String filename,String filepath){
....
}

I want to call it like this in my jsp page.

<% images image=new images(); image.imagesClass($("#filename").val(),$("filepath").val());%>

But it doesn't accept sending values to class. How do I solve this problem?

  • With AJAX-like solutions. Remember that Java/JSP is something that runs on the webserver, a machine somewhere in the Internet that makes it so your website exists and people can visit it. While the HTML/JavaScript, that contains your textbox values, is run in your visitor's browser. Two different machines. You need to use some kind of mechanism that brings these two machines to talk to each other. By default, all they do is browser asks for page and website gives page. – kumesana Apr 22 '19 at 13:32
  • There are at least three ways to achieve this. I could write you an answer but this question is unfortunately a duplicate of this one https://stackoverflow.com/questions/9566410/invoking-a-java-method-in-jsp As you will read, you can do this by using a `scriptlet`, a `servlet`, or just a simple Ajax call. – Christos Karapapas Apr 22 '19 at 15:59
  • Possible duplicate of [Invoking a Java Method in JSP](https://stackoverflow.com/questions/9566410/invoking-a-java-method-in-jsp) – Christos Karapapas Apr 22 '19 at 16:00

0 Answers0