When executing with IE two registries in data base are inserted.
When executing with Firefox a single registry is inserted.
Script:
htmltest.html
<html>
<script language="JavaScript" src="jstest.js"></script>
<form action="jsptest.jsp" method="post" name="prueba" onSubmit="return
chequea();">
<input type="submit" value="Send" class="boton"/>
</form>
</html>
jstest.js
function chequea()
{
document.prueba.submit();
return true;
}
jsptest.jsp
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%
String connectionURL =
"jdbc:mysql://127.0.0.1:3306/world?user=[myuser]&password=[mypassword]&connectionCollation=latin1_spanish_ci";
Connection connection = null;
Statement statement = null;
int UQ=0;
%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!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>Submit Question</title>
</head>
<body>
<h1>Question from MySQL</h1>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL);
statement = connection.createStatement();
CallableStatement msProcedure = connection.prepareCall("{ call P() }");
ResultSet rs = msProcedure.executeQuery();
while (rs.next())
{
out.print("Registro: " + rs.getString("ultimo") + "<br>");
}
rs.close();
msProcedure.close();
connection.close();
connection = null;
%>
</body>
</html>
MySQL Database:
DROP TABLE IF EXISTS `temporal`;
CREATE TABLE `temporal` (
`id` int(11) NOT NULL auto_increment,
`FechaHora` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_spanish_ci;
drop procedure if exists `P`;
DELIMITER $$
CREATE PROCEDURE `P`()
BEGIN
INSERT INTO temporal (FechaHora) VALUES (NOW());
SELECT LAST_INSERT_ID() AS ultimo;
END$$
DELIMITER ;
thanks!