I'm trying to run a web site using Tomcat9 Servlet, where the user will enter his salary, and according to the salary range, a readjustment will be made at that old salary! The language used is JAVA
I created the Beans and Web Packages, which were requested by the teacher, also created the html file! My HTML page is running normal, but at the time of sending the data, so that these can be "caught" and thus done the calculations I get the following error:
HTTP Status 404 - Not Found: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. willing to disclose that one exists.
And I really do not know what to do to fix this, I've seen tutorials that say to change the server location - I did and did not change at all. So I ask for help in solving the error! I am also sending my HTML codes, The code Goods and WEB!
Create a Servlet that receives the salary of a collaborator and the adjustment according to the following criterion, based on the current salary: The. wages up to R $ 280.00 (including): increase of 20% B. wages between R $ 280,00 and R $ 700,00: increase of 15% W. salaries between R $ 700.00 and R $ 1500.00: increase of 10% d. wages from R $ 1500.00 onwards: increase of 5%
CÓDIGO BEANS
package br.com.fiap.com.web;
public class Salario {
private double salario;
public Salario() {
super();
// TODO Auto-generated constructor stub
}
public Salario(double salario) {
super();
this.salario = salario;
}
public double getSalario() {
return salario;
}
public void setSalario(double salario) {
this.salario = salario;
}
public double
elseSalario (double salario ){
if(salario <= 280.00) {
salario = salario * 0.20;
}
else if(salario > 280.00 && salario < 700.00) {
salario = salario * 0.15;
}
else if(salario > 700.00 && salario < 1500.00) {
salario = salario * 0.10;
}
else if(salario > 1500.00) {
salario = salario * 0.05;
}
return salario;
}
public double
calculaPorcentagem (double salario ){
if(salario <= 280.00) {
salario = salario * 0.20;
}
else if(salario > 280.00 && salario < 700.00) {
salario = salario * 0.15;
}
else if(salario > 700.00 && salario < 1500.00) {
salario = salario * 0.10;
}
else if(salario > 1500.00) {
salario = salario * 0.05;
}
return salario;
}
}
CÒDIGO WEB
package br.com.fiap.nac.beans;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.com.fiap.com.web.Salario;
@WebServlet(urlPatterns="/salario")
public class CalcSalario extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter writer = resp.getWriter();
writer.println("<html><body>");
writer.println("Seu Salário foi Reajustado");
Salario salario = new Salario();
salario.setSalario(Double.parseDouble(req.getParameter("Salario")));
writer.println("<p>"+salario.elseSalario(salario.getSalario())+"</p>");
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Salário</title>
</head>
<body>
<h2>Vamos calcular seu novo salário?</h2>
<fieldset>
<legend>Dados:</legend>
<form action="recebe" method="get">
<label for="salario"><b>Salário:</b></label>
<input type="text" id="idsalario" name="seusalario"
placeholder="Digite o seu salário"/>
<button>Enviar</button>
</form>
</fieldset>
</body>
</html>