I am developing a Dynamic Web Project in Eclipse IDE for Java EE Developers and I would like to know if it is possible to call a java method from an HTML input tag. To be more specific, I want this <form method="post" action="/Ex2/Servlet1"> to be <form method="post" action="/Ex2/Admin.java/CreateNewUser()">. As you see, I want the input to call the function (CreateNewUser()) of class Admin and then this function to call Servlet1. Admin's function will be in the "middle" of the whole process.
Asked
Active
Viewed 83 times
0
JimHawkins
- 4,843
- 8
- 35
- 55
Xaris
- 73
- 1
- 7
2 Answers
0
You can't call a Java method from HTML, HTML is interpreted in the browser and it only can send HTTP requests to a HTTP server, the requests are processed by servlets (apart from filters and other) so you need to have a servlet to process the request.
Antonio Martínez
- 41
- 3
0
Actually you can call some Java method from your JSP file, adding scriptlet scriptlets but is not a good practice.
I would recommend just use a proper endpoint in your action attribute, send the form to the controller, do all actions you need, create that user and redirect to any page you need.
EDIT KISS :)
To clarify....
cralfaro
- 5,822
- 3
- 20
- 30
-
Wow "KISS" really? I wonder the pace we are progressing in innovating closing messages. LOL – XOR-Manik Jun 03 '16 at 15:30
-
@XOR-Manik better if i add a link haha – cralfaro Jun 03 '16 at 15:35
-
Haha; it was sarcasm! @cralfaro but yes link clear the things out haha! – XOR-Manik Jun 03 '16 at 15:39