Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/02/2013, 02:11
remart20
 
Fecha de Ingreso: febrero-2013
Mensajes: 1
Antigüedad: 11 años, 3 meses
Puntos: 0
Programacion web en Eclipse

Estimados compañeros buenas noches:

Se que deben estar casi aburridos de ayudar a persona que recien inician el mundo de la programacion, pero me ariesgare debido a que es es de vital imprtancia mi desarrollo en el area. Hoy tuve una practica en la universidad donde pedian mostrar en pantalla web la solucion de una ecuacion de segundo grado, esto editando dos archivos: el controller y el jsp.
Mis archivos son los siguientes:
Controller:
package trastienda.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMap ping;
import org.springframework.web.bind.annotation.RequestMet hod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class EcuacionController {

@RequestMapping(value = "/ecuacion") //, method = RequestMethod.GET)
protected ModelAndView inicio(HttpServletRequest request,
HttpServletResponse response) throws Exception {

return new ModelAndView("proceso");
}

@RequestMapping(value = "/calculo")
protected ModelAndView calculo(HttpServletRequest request,
HttpServletResponse response) throws Exception {
//1. Recuperar los datos
String uno=request.getParameter("txtA");// nombre de la caja de texto
String dos=request.getParameter("txtB");// nombre de la caja de texto
String tres=request.getParameter("txtC");// nombre de la caja de texto
String op=request.getParameter("op");

double resultado=0.0;
double A=9, B=6, C=4;

double X1=0, X2=0, G=0, I=0, D=0;
D=(B*B-(4*A*C));
if (D>0)
{
// si las reices son positivas
X1=(-B+Math.sqrt(D))/(2*A);
X2=(-B-Math.sqrt(D))/(2*A);
System.out.println("X1="+X1);
System.out.println("X2="+X2);
}
else
{
// si las raices son negativas

G=-B/(2*A);
I=Math.sqrt(-D)/(2*A);
System.out.println("X1="+""+G+"+"+I+"j");
System.out.println("X2="+""+G+"-"+I+"j");
return new ModelAndView("proceso"); //, "MENSAJE", "Pendiente!!!");
}
}
y el jsp:
<jsp:directive.page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Insert title here</title>
</head>
<body>
<h3>Ecuación de Segundo Grado</h3>
<form action="calcular.html" method="post" onsubmit="return valida();">
<table>
<tr>
<td>a</td>
<td><input name="txtA"/></td>
</tr>
<tr>
<td>b</td>
<td><input name="txtB"/></td>
</tr>
<tr>
<td>c</td>
<td><input name="textC"/></td>
</tr>
<tr>
<td/>
<td><input type="submit"/></td>
</tr>
</table>
</form>
${RES }
</body>
</html>

Amigos se que es ucho lo que pido con tan poco que he dado, pero si pudieran darme algun alcance de como avanzar poco a poco se los garadeceria. Muchas gracias de antemano