y estoy algo perdido ya que aun no se los codigos para hacer cada cosa.
bueno me pueden guiar???? por favor!!!
la idea es hace runa calculadora bien basica
les dejo mi codigo
html
Cita:
servlet<html>
<title>Calculadora Muda</title>
<body>
<br/>
<table border>
<tr>
<td bGCOLOR=#00FF00> <b><FONT SIZE=5>X</FONT></b>: </td>
<td bGCOLOR=#FFFF00>
x:<input NAME="x" VALUE="0"></input> </td>
</tr>
<tr>
<td bGCOLOR=#00FF00> <b><FONT SIZE=5>Y</FONT></b>: </td>
<td bGCOLOR=#FFFF00>
y:<input NAME="y" VALUE="0"></input></td>
</tr>
<tr>
<td COLSPAN=2 bGCOLOR=#93DB70 >
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="+"></INPUT>
</form>
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="-"></INPUT>
</form>
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="*"></INPUT>
</form>
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="/"></INPUT>
</form>
</td>
</tr>
<tr>
<td bGCOLOR=#FFFF00> <b><FONT SIZE=5>Resultado</FONT></b>: </td>
<td bGCOLOR=#00FF00> <form method=get action="CalcS"><FONT SIZE=5>0</FONT></form></td>
</tr>
</table border>
<
</body>
</SCRIPT>
</html>
<title>Calculadora Muda</title>
<body>
<br/>
<table border>
<tr>
<td bGCOLOR=#00FF00> <b><FONT SIZE=5>X</FONT></b>: </td>
<td bGCOLOR=#FFFF00>
x:<input NAME="x" VALUE="0"></input> </td>
</tr>
<tr>
<td bGCOLOR=#00FF00> <b><FONT SIZE=5>Y</FONT></b>: </td>
<td bGCOLOR=#FFFF00>
y:<input NAME="y" VALUE="0"></input></td>
</tr>
<tr>
<td COLSPAN=2 bGCOLOR=#93DB70 >
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="+"></INPUT>
</form>
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="-"></INPUT>
</form>
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="*"></INPUT>
</form>
<form method=get action="CalcS">
<INPUT TYPE="submit" NAME="op1" VALUE="/"></INPUT>
</form>
</td>
</tr>
<tr>
<td bGCOLOR=#FFFF00> <b><FONT SIZE=5>Resultado</FONT></b>: </td>
<td bGCOLOR=#00FF00> <form method=get action="CalcS"><FONT SIZE=5>0</FONT></form></td>
</tr>
</table border>
<
</body>
</SCRIPT>
</html>
Cita:
Plzzz cualquier ayuda sera bien recibida ya que estoy algo perdidoimport java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CalcS extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
String x = request.getParameter("x");
String y = request.getParameter("y");
String op=request.getParameter("op");
int par1=Integer.parseInt(x);
int par2=Integer.parseInt(y);
int result=-1;
if (op.equals("+"))
result = par1+par2;
else if (op.equals("-"))
result = par1-par2;
else if (op.equals("*"))
result = par1*par2;
else if(op.equals("/"))
result = par1/par2;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(""+result);
}
}
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CalcS extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
String x = request.getParameter("x");
String y = request.getParameter("y");
String op=request.getParameter("op");
int par1=Integer.parseInt(x);
int par2=Integer.parseInt(y);
int result=-1;
if (op.equals("+"))
result = par1+par2;
else if (op.equals("-"))
result = par1-par2;
else if (op.equals("*"))
result = par1*par2;
else if(op.equals("/"))
result = par1/par2;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(""+result);
}
}
Saludos
pd:existe un buen Api para servlet?