How to call java method in jsp page on button click?



How to call java method in jsp page on button click?..

Answer / Vishal Kumar Tiwari

To call a Java method in a JSP page on button click, you can use the scriptlet syntax or JavaBeans components. Here is an example using scriptlets: n```jspn<html>n<body>n<form action='' method='post'> <!-- form submission will trigger the script -->n <input type='submit' value='Submit' />n<script language='java'> <!-- Java scriptlet -->n public void _init() { request.setCommand("myMethod"); }n</script>n</body></html>``` In this example, myMethod is a method in the JSP page's underlying servlet.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JSP Interview Questions

Why jsp is better over static html also explain lifecycle of a jsp?

1 Answers  


How do I perform browser redirection from a jsp page?

1 Answers  


Which two interfaces does the javax servlet jsp package have?

1 Answers  


What is jsp servlet?

1 Answers  


What is the difference between JSP and Servlet?

21 Answers   HCL, T3 Softwares, Tibco,


What are the components that make up a tag library in jsp?

1 Answers  


A jsp page, include.jsp, has a instance variable "int a", now this page is statically included in another jsp page, index.jsp, which has a instance variable "int a" declared. What happens when the index.jsp page is requested by the client?

1 Answers  


Explain the advantages of jsp?

1 Answers  


i am using rich faces datatable rich:datatable. On entering the value, values get filtered in table. Now how can i get the value in back9ing bean..?

1 Answers  


What is the use of jstl tags in jsp?

1 Answers  


How to implement a thread-safe jsp page?

3 Answers  


What is the use of jstl?

1 Answers  


Categories