Rafcord
Rafcord
CC#
Created by Rafcord on 2/4/2024 in #help
✅ Method doGet create error 404.
I'm trying to create a servlet, but it doesn't work at all. The first page is displayed, but the response only displays a 404 error.
<!DOCTYPE html>
<html>
<head>
<title>MVC Servlet</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2>Solar System</h2>
<form action="Result" method="get">
<p>How many planets you want to enter:<input type=number name=numberOfPlanets ></p>
<input type="submit" value="Enter" />
</form>
</body>
</html>

@WebServlet("/Result")
public class Kontroler extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String numberOfNewPlanets = request.getParameter("numberOfPlanets");
int numberOfPlanets = Integer.parseInt(numberOfNewPlanets);

PrintWriter out = response.getWriter();
String htmlRespone = "<html>";
htmlRespone += "Your numberOfPlanets is: " + numberOfPlanets + "<br/>";
htmlRespone += "</html>";

out.println(htmlRespone);
}
}
<!DOCTYPE html>
<html>
<head>
<title>MVC Servlet</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h2>Solar System</h2>
<form action="Result" method="get">
<p>How many planets you want to enter:<input type=number name=numberOfPlanets ></p>
<input type="submit" value="Enter" />
</form>
</body>
</html>

@WebServlet("/Result")
public class Kontroler extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String numberOfNewPlanets = request.getParameter("numberOfPlanets");
int numberOfPlanets = Integer.parseInt(numberOfNewPlanets);

PrintWriter out = response.getWriter();
String htmlRespone = "<html>";
htmlRespone += "Your numberOfPlanets is: " + numberOfPlanets + "<br/>";
htmlRespone += "</html>";

out.println(htmlRespone);
}
}
16 replies
CC#
Created by Rafcord on 1/29/2024 in #help
Button showing password.
I want to add button that shows password. How can I do that? This is my code:
string encryptedPassword = "";

for (int i = 0; i < Model.Password.Length; i++)
{
encryptedPassword += "*";
}

<p ALIGN="LEFT"><b>Id:</b> @Model.Id </p>
<p ALIGN="LEFT"><b>Rank: </b> @Model.Ranks</p>
<p ALIGN="LEFT"><b>Nick: </b> @Model.Nick</p>
<p ALIGN="LEFT"><b>Email:</b> @Model.Login. </p>
<p ALIGN="LEFT"><b>Password:</b> @encryptedPassword </p>
<button ALIGN="LEFT" type="button">Show password</button>
string encryptedPassword = "";

for (int i = 0; i < Model.Password.Length; i++)
{
encryptedPassword += "*";
}

<p ALIGN="LEFT"><b>Id:</b> @Model.Id </p>
<p ALIGN="LEFT"><b>Rank: </b> @Model.Ranks</p>
<p ALIGN="LEFT"><b>Nick: </b> @Model.Nick</p>
<p ALIGN="LEFT"><b>Email:</b> @Model.Login. </p>
<p ALIGN="LEFT"><b>Password:</b> @encryptedPassword </p>
<button ALIGN="LEFT" type="button">Show password</button>
12 replies
CC#
Created by Rafcord on 12/14/2023 in #help
No toolbox in the windows forms application project.
I created project in Visual Studio 2022 like in this video: https://www.youtube.com/watch?v=JSJ1JI2alJg but I don't have toolbox in my project. Does anyone know what the solution to this could be?
6 replies