I wrote the JSP page and post the form by auto submit (JavaScript) code to the servlet.
In servlet I print result once but when I execute the app I get out put more than once. JSP:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
<script type="text/javascript" src="/src/js/tableform.js"></script>
<link rel="stylesheet" type="text/css" href="/css/table.css">
</head>
<body>
<form id="myForm" name="LOAD" action="/gridview" method="post">
<input type="hidden" name="pageAction" value="readTable">
</form>
</body>
<script>
setTimeout(submitform,0);
function submitform()
{
//alert('test');
document.getElementById("myForm").submit();
}
</script>
</html>
Servlet doPost
:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("here");
String pageAction = request.getParameter("pageAction");
System.out.println(pageAction);
}
OUTPUT:
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable
here
readTable