Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Http Status 404 not found

SETH YOMBAFeb 24 2025 — edited Feb 26 2025

I have a rock paper scissor game here is the problem statement:

Sipho is a Software Developer at WeDoWebApps. He is supervised by Ms Baloyi, a Senior Developer. As his first task, Ms Baloyi invites Sipho to participate in a project to create the well-known Rock Paper Scissor game for a client. The task given to Sipho is to develop a web application that will allow a user to play the Rock Paper Scissor game with the computer. The game is played as follows: • Two players simultaneously punch their clenched fists against an open hand and shout “Rock, Paper, Scissor, shoot”. After saying shoot, they each show a rock, paper, or scissor sign. • A winner is then determined as follows: • A rock crushes a scissor. So the player with a rock sign wins. • A paper wraps a rock. The player with a paper sign wins. • A scissor cuts paper. The scissor player wins. If both players show the same sign, it’s a tie. So, in this challenge, Sipho must create a web application that will simulate the Rock Paper Scissor game. A user will play the game against a computer character called Siri. When the game starts, Siri will do a Rock Paper Scissor sign, and without revealing it, challenges the player to do theirs. A comparison is made and the winner is declared. The following game outcome is displayed after each game played: • Siri’s sign. • Player’s sign. • Outcome (whether the player has won, lost, or tied).

here are the files i created:

<!DOCTYPE html>
<!--

-->
<html>
<head>
<title>Rock Paper Scissor App</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>Welcome</h1>
<p>
Welcome to our Rock Paper Scissor App. Click <a href="options.jsp">here</a> to start.
</p>

</body>
</html>

my options.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Make your choice</title>
</head>
<body>
<h1>Choose your sign</h1>
<%
// L'ordinateur fait son choix en secret
String[] choixPossibles = {"Pierre", "Papier", "Ciseaux"};
String ordinateurChoix = choixPossibles[(int) (Math.random() * 3)];
%>

   \<form action="result.jsp" method="get">  
   \<!-- Le choix de l'ordinateur est caché -->  
   \<input type="hidden" name="ordinateurChoix" value="\<%= ordinateurChoix %>">  
     
   \<input type="radio" name="utilisateurChoix" value="Pierre" required> Pierre\<br>  
   \<input type="radio" name="utilisateurChoix" value="Papier"> Papier\<br>  
   \<input type="radio" name="utilisateurChoix" value="Ciseaux"> Ciseaux\<br>\<br>  
     
   \<button type="submit">Valider votre choix\</button>  

</form>
</body>
</html>

my results.jsp file

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Résultat</title>
</head>
<body>
<h1>Résultat du jeu :</h1>

<%
String ordinateurChoix = request.getParameter("ordinateurChoix");
String utilisateurChoix = request.getParameter("utilisateurChoix");

   String resultat = "";  
   if (utilisateurChoix.equals(ordinateurChoix)) {  
       resultat = "Égalité !";  
   } else if (  
       (utilisateurChoix.equals("Pierre") && ordinateurChoix.equals("Ciseaux")) ||  
       (utilisateurChoix.equals("Papier") && ordinateurChoix.equals("Pierre")) ||  
       (utilisateurChoix.equals("Ciseaux") && ordinateurChoix.equals("Papier"))  
   ) {  
       resultat = "Vous avez gagné !";  
   } else {  
       resultat = "Vous avez perdu !";  
   }  

%>

<p>Votre choix : <%= utilisateurChoix %></p>
<p>Choix de l'ordinateur : <%= ordinateurChoix %></p>
<h2><%= resultat %></h2>
<a href="index.html">Rejouer</a>
</body>
</html>

and all this give me a http status 404 not found, when i choose an option

Comments
Post Details
Added on Feb 24 2025
0 comments
98 views