I'm guessing that you want to execute the procedure whenever someone accesses JSP-File x.jsp.
While it is possible to run Java code form inside a JSP-File, I would never recommend it. You might ask why, but this has been documented better than I ever could in this post.
To answer your question, you need to create a servlet
@WebServlet("/YourServlet")
public class YourServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public YourServlet() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
new Execute.run();
request.getRequestDispatcher("/WEB-INF/_search.jsp").forward(request, response);
}
}
Furthermore you will have to change the permissions of your webapp. Which is documented on this page.
Mind that this is the most basic approach, not the cleanest one. Usually execution of any java code (that controls the execution plan) is done within services. You can add a service to you application by (agian) declaring a HttpServlet and declaring a service there.
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
new Execute.run();
if (view.equals(request.getPathInfo().substring(1)) {
request.getRequestDispatcher("/WEB-INF/" + view + ".jsp").forward(request, response);
} else {
response.sendRedirect(view);
}
} catch (Exception e) {
throw new ServletException("Executing action failed.", e);
}
}
While I don't know what the comment below means, I'll add the html-code to the answer to make it more complete. In practice this would mean:
On submit the html needs to make an HTTP-Post to the servlet.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<table align="center" border="3">
<tr>
<td><form action='Myactionhandle'><input type="submit" value="submit" name="submit"/></form></td>
</tr>
</table>
</body>
</html>
And the servlet has to execute the code.
@WebServlet("/Myactionhandle")
public class YourServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public YourServlet() {
super();
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
new Execute.run();
request.getRequestDispatcher("/WEB-INF/_search.jsp").forward(request, response);
}
}