I have a dynamic web project. In src
folder I have Java class with couple of methods. Let us suppose index.html
file has two buttons.on click of the button how can I call the Java class. Is there any possibility of doing so?
Asked
Active
Viewed 3,926 times
3

halfer
- 19,824
- 17
- 99
- 186

user3007385
- 153
- 4
- 15
-
2Did you try with `JSP`? – Rong Nguyen Jun 10 '14 at 10:52
-
or do you mix up Java with JavaScript (this is not the same). Java should be not used in normal webpages and you should use a Java framework and Java server (which use JSP) - but you can try a Java applet (may not be very secure and blocked) – Jun 10 '14 at 10:59
4 Answers
0
Create servlet which will handle get/post requests, invoke your java code and return result.
http://docs.oracle.com/cd/E19857-01/819-6518/abxbh/index.html http://www.oracle.com/technetwork/java/servlet-142430.html

Kasper Ziemianek
- 1,329
- 8
- 15
0
You have to use JSP. Here is a simple tutorial that could be useful to start. JSP tutorial
Good luck!

csadan
- 291
- 1
- 3
- 13
0
You should work with frameworks. I recommend you SPRING MVC. It`s very good and easy to use. For calling a java class you need jQuery and the framework.

Jason Aller
- 3,541
- 28
- 38
- 38

Chirila Marc-Mihai
- 51
- 3