Is there a way to call a Java Servlet on click of hyperlink without using JavaScript?
Make the hyperlink have a URL that you have a servlet mapping defined for in the web.xml file.
The servlet-mapping element defines a mapping between a servlet and a URL pattern. The example below maps the servlet named myservlet to any URL that starts with /foo:
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>com.stackoverflow.examples.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/foo/*</url-pattern>
</servlet-mapping>
<a href="/foo/test.html">Click Me</a> would invoke the servlet.web.xml by setting its name, class and url-pattern
(let's say your url-pattern is /myServlet)<a href="/myServlet">mylink</a>
doGet(..) method of the servlet to do whatever you wantIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With