Commit ade207a4 by Cristian

inicial proyect

parent 461c21a4
......@@ -10,17 +10,21 @@
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body class="container">
<% ArrayList<Float>resultado=(ArrayList<Float>) request.getAttribute("resultado");
String tipo =request.getAttribute("P0").toString();
if(tipo.toLowerCase().equals("c")){
<%
ArrayList<Float> resultado= new ArrayList<Float>();
String tipo="";
if(request.getAttribute("array")!=null && request.getAttribute("P0")!=null){
resultado= (ArrayList<Float>) request.getAttribute("array");
tipo =request.getAttribute("P0").toString();
if(tipo.toLowerCase().equals("c")){
tipo=" Celsius";
}else if(tipo.toLowerCase().equals("f")){
}else if(tipo.toLowerCase().equals("f")){
tipo=" Fahrenheit";
}else{
}else{
tipo=" Kelvin";
}
}
%>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
......
......@@ -11,7 +11,7 @@
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous">
</head>
<body>
<body class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Menu</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
......@@ -34,10 +34,10 @@
</li>
</div>
</nav>
</body class="container">
<%Exception resultado= null;
</body >
<%String resultado= "";
if (request.getAttribute("resultado")!=null){
resultado= (Exception) request.getAttribute("resultado");
resultado= (String) request.getAttribute("resultado");
}
%>
<h1><%=resultado.toString() %></h1>
......
......@@ -41,40 +41,37 @@ public class ConversorServlet extends HttpServlet {
// TODO Auto-generated method stub
doGet(request, response);
ArrayList<Float>resultado= new ArrayList<Float>();
System.out.println("P1");
int error=0;
try {
if(request.getParameter("P1")!=null && request.getParameter("P0")!=null) {
System.out.println(request.getParameter("P0").toString());
String p0= request.getParameter("P0").toString();
if(!"c".equals(p0)|| !"k".equals(p0)|| !"f".equals(p0)) {
request.setAttribute("resultado", "valor de palo no esperado");
RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
if (rd != null) {
rd.forward(request, response);
}
System.out.println(request.getParameter("P1").toString());
String p0=(String) request.getParameter("P0");
if(("C".equals(p0.toUpperCase())) || ("K".equals(p0.toUpperCase())) || ("F".equals(p0.toUpperCase()))) {
}else {
error=1;
}
resultado = convertidor(request.getParameter("P0").toString(),Float.parseFloat(request.getParameter("P1")));
System.out.println("aca llego");
request.setAttribute("P0", request.getParameter("P0"));
request.setAttribute("P1", request.getParameter("P1"));
request.setAttribute("resultado", resultado);
request.setAttribute("array", resultado);
}else {
request.setAttribute("resultado", "Parametros nulos");
RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
if (rd != null) {
rd.forward(request, response);
}
error=2;
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("exploto");
request.setAttribute("resultado", "el valor no es numerico");
RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
if (rd != null) {
rd.forward(request, response);
}
error=3;
/*PrintWriter respuesta= response.getWriter();
respuesta.println("<!DOCTYPE html>");
......@@ -91,10 +88,33 @@ public class ConversorServlet extends HttpServlet {
}
finally {
if(error==1) {
request.setAttribute("resultado", "valor de palo no esperado");
RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
if (rd != null) {
rd.forward(request, response);
}
}else if(error==2){
request.setAttribute("resultado", "Parametros nulos");
RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
if (rd != null) {
rd.forward(request, response);
}
}else if(error==3){
request.setAttribute("resultado", "el valor no es numerico");
RequestDispatcher rd = request.getRequestDispatcher("Error.jsp");
if (rd != null) {
rd.forward(request, response);
}
}else {
RequestDispatcher rd = request.getRequestDispatcher("/ConversorResultado.jsp");
if (rd != null) {
rd.forward(request, response);
}
}
PrintWriter respuesta=response.getWriter();
respuesta.println("<!DOCTYPE html>");
respuesta.print("<html>");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment