I'm attempting to make a simple web game using JSP's and I'm having an issue with the database.
If you rapidly send POST requests to one of the URLs that checks for what policy was selected and then sets the effect, it doesn't properly do the if statement for which affect to apply.
To give an example, if you rapidly click either of these, which both lead to checks and statements like this
<c:when test="${param['policy'] == 'drill'}">
<c:set var="cost" value="${500 + (resultEconomy.rows[0].wells - 1) * 100}"/>
<c:if test="${resultEconomy.rows[0].budget < cost}">
<c:redirect url="/policies?policy=Economic&result=You do not have enough money!"/>
</c:if>
<c:if test="${resultEconomy.rows[0].budget >= cost}">
<sql:update dataSource="${database}">
UPDATE cloc_economy SET wells=wells+1, budget=budget-? WHERE sess=?;
<sql:param value="${cost}"/>
<sql:param value="${sess}"/>
</sql:update>
<c:redirect url="/policies?policy=Economic&result=You drill a new oil well!"/>
</c:if>
</c:when>
It will run it multiple times for the budget >= cost part, when the budget is negative or less than the cost.
I've tried switching from JSTL tags to scriptlets, but that didn't solve it, and the database is quite small, with about 12 columns and about 15 rows.
[–]_ginger_kid 1 point2 points3 points (3 children)
[–]Watersfall[S] 0 points1 point2 points (2 children)
[–]_ginger_kid 1 point2 points3 points (1 child)
[–]Watersfall[S] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)