Skip to content

Commit

Permalink
Fixed critical bug
Browse files Browse the repository at this point in the history
mashinakatherina committed Jan 3, 2021
1 parent d00dccf commit 599669d
Showing 6 changed files with 29 additions and 28 deletions.
17 changes: 9 additions & 8 deletions information_system/src/ifmo/ChampionshipResults.java
Original file line number Diff line number Diff line change
@@ -43,18 +43,19 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
"SELECT place, final_score, name, special_award FROM score " +
"JOIN team ON score.team_id = team.team_id WHERE championship_id = ?");

st.setString(1, request.getParameter("result_championship_id"));
st.setInt(1, Integer.valueOf(request.getParameter("result_championship_id")));

ResultSet rs = st.executeQuery();

rs.next();
String curPlace = rs.getString("place");
String curScore =rs.getString("final_score");
String curName = rs.getString("name");
String curAward = rs.getString("special_award");
while (rs.next()) {
String curPlace = rs.getString("place");
String curScore = rs.getString("final_score");
String curName = rs.getString("name");
String curAward = rs.getString("special_award");

Championship championship = new Championship(curPlace, curScore, curName, curAward);
championships.add(championship);
Championship championship = new Championship(curPlace, curScore, curName, curAward);
championships.add(championship);
}

st.close();
con.close();
4 changes: 2 additions & 2 deletions information_system/src/ifmo/FinishChampionship.java
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
import java.sql.Connection;
import java.sql.PreparedStatement;

@WebServlet("/EndChampionship")
@WebServlet("/FinishChampionship")
public class FinishChampionship extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
@@ -22,7 +22,7 @@ protected void doPost(HttpServletRequest request,
.prepareStatement("SELECT end_championship(?);");


st.setString(1, request.getParameter("end_championship_id"));
st.setInt(1, Integer.valueOf(request.getParameter("end_championship_id")));


st.executeQuery();
14 changes: 7 additions & 7 deletions information_system/src/ifmo/InformationAboutPerson.java
Original file line number Diff line number Diff line change
@@ -47,14 +47,14 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
st.setString(1, request.getParameter("search_last_name"));
ResultSet rs = st.executeQuery();

rs.next();
String curUserFirstName = rs.getString("first_name");
String curUserLastName = rs.getString("last_name");
String curUserBirthDate = rs.getString("birth_date");

Person p = new Person(curUserFirstName, curUserLastName, curUserBirthDate);
list.add(p);
while (rs.next()) {
String curUserFirstName = rs.getString("first_name");
String curUserLastName = rs.getString("last_name");
String curUserBirthDate = rs.getString("birth_date");

Person p = new Person(curUserFirstName, curUserLastName, curUserBirthDate);
list.add(p);
}
response.sendRedirect("info_response.jsp");
st.close();
con.close();
2 changes: 1 addition & 1 deletion information_system/src/ifmo/StartChampionship.java
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ protected void doPost(HttpServletRequest request,
PreparedStatement st = con
.prepareStatement("SELECT start_championship(?);");

st.setString(1, request.getParameter("start_championship_id"));
st.setInt(1, Integer.valueOf(request.getParameter("start_championship_id")));

st.executeQuery();

8 changes: 4 additions & 4 deletions information_system/web/results.jsp
Original file line number Diff line number Diff line change
@@ -23,9 +23,10 @@
<p class="subtitle_form"> Get results of championship</p>

<p>
<select class="reg_text_in_form" id="result_championship_id" type="text" name="result_championship_id" style="width: 690px"> <!--Supplement an id here instead of using 'name'-->
<select class="reg_text_in_form" id="result_championship_id" type="text" name="result_championship_id"
style="width: 690px"> <!--Supplement an id here instead of using 'name'-->
<option value="0" selected>Select championship id</option>
<option value="1" >1</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
@@ -41,8 +42,7 @@


<div>
<button class="region" type="submit" id="start-championship-submit-button">Start
championship
<button class="region" type="submit" id="start-championship-submit-button">Get results
</button>


12 changes: 6 additions & 6 deletions information_system/web/results_response.jsp
Original file line number Diff line number Diff line change
@@ -24,14 +24,14 @@
<table align="right" class="block content" id = responsesTable style="margin-top: 110px; width: 700px" >
<tr><td>Place</td><td>Team name</td><td>Score</td><td>Award</td></tr>
<%
ArrayList<Championship> list = (ArrayList)config.getServletContext().getAttribute("list");
for(int i = 0; i < list.size(); i++) {
ArrayList<Championship> championships = (ArrayList)config.getServletContext().getAttribute("championships");
for(int i = 0; i < championships.size(); i++) {
%>
<tr>
<td><%=list.get(i).place%></td>
<td><%=list.get(i).team_name%></td>
<td><%=list.get(i).score%></td>
<td><%=list.get(i).award%></td>
<td><%=championships.get(i).place%></td>
<td><%=championships.get(i).team_name%></td>
<td><%=championships.get(i).score%></td>
<td><%=championships.get(i).award%></td>

</tr>

0 comments on commit 599669d

Please sign in to comment.