0

This is in reference to this stack overflow post. I want to do something similar: on a specific event, I want the JavaScript to call the Ajax function which would then call the Java method. The person who answered the questions said to create a JSP file (for the java code). My java code use JAR files, so I could you import these JAR files to a JSP file? Would a better approach be to create a servlet?

(As a side note, would the JSP file contain all of my Java code?)

4
  • jsp can import classes as in java, but I would prefeer a servlet, maybe easier to setup and all code in compiler... then your ajax just call the servlet that can return the result with for example json. However what is best becomes a non answerable question (opinion based) Commented Oct 2, 2015 at 23:05
  • Ok got it. I am going to use the servlet then and am going to use that, Eclipse, and Tomcat to set up the server and all. What I d not know is how would I actually connect my server (in Eclipse with the Tomcat) to a html file that I already have that is running up on the internet? Commented Oct 2, 2015 at 23:35
  • I guess that the question is how the html file connects to your server.. That can be a problem both because you need a visibile ip on your server and browser do not like to call other ip's from javascript. My suggestion is that you need someone that "house" your tomcat solution (servlet and html) on same server (Note you have same problem with jsp) Commented Oct 2, 2015 at 23:39
  • Maybe if you already have a domain and on the domain you can run PHP or ASP, you could solve your problem using these scripting languages, naturally no more importing jars... Commented Oct 2, 2015 at 23:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.