Enviado por luz_angel el día 23 de junio de 2006
Hola, Tengo un servlet que almacena el porcentaje de ciertos meses y asi mismo hace un calculo despues de guardar los datos para saber si llego al 100% o es menos o si es mas, el problema es cuando le mando el mensaje al usuario de que si se paso o si le falto para llegar al 100% tiene que mostrarme el resultado de la suma ¿como le hago? El valor de la suma se encuentra en ok1...por favor ayuda....
Codigo de mi servlet....
package suministros;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import persistencia.InformacionObras;
import persistencia.Licitaciones;
import persistencia.suministros;
import reglas.SuministrosReglas;
/**
* @version 1.0
* @author
*/
public class ModifSumSubProgServlet extends HttpServlet {
//private int valor=0;
/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
SuministrosReglas objregsum = new SuministrosReglas();
suministros objsuministros= new suministros();
Vector vids= new Vector();
String idse,idfs,idco,ids;
int intidco=0;
boolean ok=false,ok2=false;
//Vector ok1= new Vector();
int c=100;
int ok1=0;
//private String ok6=null;
// valor=ok1;
Licitaciones objlicitaciones= new Licitaciones();
InformacionObras objinfobras= new InformacionObras();
HttpSession session=req.getSession(true);
String licitacion = (String) session.getAttribute(\\\\\\\"licitacion\\\\\\\");
session.setAttribute(\\\\\\\"licitacion\\\\\\\",licitacion);
String subestacion = (String) session.getAttribute(\\\\\\\"subestacion\\\\\\\");
session.setAttribute(\\\\\\\"subestacion\\\\\\\",subestacion);
String usuario = (String) session.getAttribute(\\\\\\\"usuario\\\\\\\");
session.setAttribute(\\\\\\\"usuario\\\\\\\",usuario);
String idlicitacion=objlicitaciones.getidLic(licitacion);
String idsubestacion=objinfobras.getIdSE(subestacion);
String idusuario=usuario;
String estadolic=objsuministros.getEstadoLic(idlicitacion);
if(estadolic.equals(\\\\\\\"VF\\\\\\\"))
printDataErrorLic(req,resp);
else
{
ids=req.getParameter(\\\\\\\"suministro\\\\\\\");
if(req.getParameter(\\\\\\\"suministro\\\\\\\").toString().equals(\\\\\\\"0\\\\\\\"))
printDataError(req,resp);
else
{
vids=objregsum.separaids(ids);
idse=vids.get(0).toString();
idfs=vids.get(1).toString();
idco=vids.get(2).toString();
intidco=Integer.parseInt(idco);
String descripcion=req.getParameter(\\\\\\\"descripcion\\\\\\\");
String m1=req.getParameter(\\\\\\\"1\\\\\\\"),m2=req.getParameter(\\\\\\\"2\\\\\\\"),m3=req.getParameter(\\\\\\\"3\\\\\\\"),m4=req.getParameter(\\\\\\\"4\\\\\\\"),m5=req.getParameter(\\\\\\\"5\\\\\\\"),
m6=req.getParameter(\\\\\\\"6\\\\\\\"),m7=req.getParameter(\\\\\\\"7\\\\\\\"),m8=req.getParameter(\\\\\\\"8\\\\\\\"),m9=req.getParameter(\\\\\\\"9\\\\\\\"),m10=req.getParameter(\\\\\\\"10\\\\\\\"),
m11=req.getParameter(\\\\\\\"11\\\\\\\"),m12=req.getParameter(\\\\\\\"12\\\\\\\"),m13=req.getParameter(\\\\\\\"13\\\\\\\"),m14=req.getParameter(\\\\\\\"14\\\\\\\"),m15=req.getParameter(\\\\\\\"15\\\\\\\"),
m16=req.getParameter(\\\\\\\"16\\\\\\\"),m17=req.getParameter(\\\\\\\"17\\\\\\\"),m18=req.getParameter(\\\\\\\"18\\\\\\\"),m19=req.getParameter(\\\\\\\"19\\\\\\\"),m20=req.getParameter(\\\\\\\"20\\\\\\\"),
m21=req.getParameter(\\\\\\\"21\\\\\\\"),m22=req.getParameter(\\\\\\\"22\\\\\\\"),m23=req.getParameter(\\\\\\\"23\\\\\\\"),m24=req.getParameter(\\\\\\\"24\\\\\\\"),m25=req.getParameter(\\\\\\\"25\\\\\\\"),
m26=req.getParameter(\\\\\\\"26\\\\\\\"),m27=req.getParameter(\\\\\\\"27\\\\\\\"),m28=req.getParameter(\\\\\\\"28\\\\\\\"),m29=req.getParameter(\\\\\\\"29\\\\\\\"),m30=req.getParameter(\\\\\\\"30\\\\\\\");
if(m1==null)m1=\\\\\\\"0\\\\\\\";
if(m2==null)m2=\\\\\\\"0\\\\\\\";
if(m3==null)m3=\\\\\\\"0\\\\\\\";
if(m4==null)m4=\\\\\\\"0\\\\\\\";
if(m5==null)m5=\\\\\\\"0\\\\\\\";
if(m6==null)m6=\\\\\\\"0\\\\\\\";
if(m7==null)m7=\\\\\\\"0\\\\\\\";
if(m8==null)m8=\\\\\\\"0\\\\\\\";
if(m9==null)m9=\\\\\\\"0\\\\\\\";
if(m10==null)m10=\\\\\\\"0\\\\\\\";
if(m11==null)m11=\\\\\\\"0\\\\\\\";if(m12==null)m12=\\\\\\\"0\\\\\\\";if(m13==null)m13=\\\\\\\"0\\\\\\\";if(m14==null)m14=\\\\\\\"0\\\\\\\";if(m15==null)m15=\\\\\\\"0\\\\\\\";if(m16==null)m16=\\\\\\\"0\\\\\\\";if(m17==null)m17=\\\\\\\"0\\\\\\\";if(m18==null)m18=\\\\\\\"0\\\\\\\";if(m19==null)m19=\\\\\\\"0\\\\\\\";if(m20==null)m20=\\\\\\\"0\\\\\\\";
if(m21==null)m21=\\\\\\\"0\\\\\\\";if(m22==null)m22=\\\\\\\"0\\\\\\\";if(m23==null)m23=\\\\\\\"0\\\\\\\";if(m24==null)m24=\\\\\\\"0\\\\\\\";if(m25==null)m25=\\\\\\\"0\\\\\\\";if(m26==null)m26=\\\\\\\"0\\\\\\\";if(m27==null)m27=\\\\\\\"0\\\\\\\";if(m28==null)m28=\\\\\\\"0\\\\\\\";if(m29==null)m29=\\\\\\\"0\\\\\\\";if(m30==null)m30=\\\\\\\"0\\\\\\\";
Date fechactual= new Date();
SimpleDateFormat formato = new SimpleDateFormat(\\\\\\\"yyyyMMdd\\\\\\\");
String cadenafecha = formato.format(fechactual);
String sCambios=objregsum.getStringSumApCFEProgAntDesp(ids,descripcion,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,
m16,m17,m18,m19,m20,m21,m22,m23,m24,m25,m26,m27,m28,m29,m30);
ok=objsuministros.UpdateSumSubApCFEProg(idse,idfs,intidco,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,
m16,m17,m18,m19,m20,m21,m22,m23,m24,m25,m26,m27,m28,m29,m30);
//String ValorTotal=req.getParameter(\\\\\\\"ok1\\\\\\\");
if(ok)
{
if(objsuministros.getEstadoLic(idlicitacion).equals(\\\\\\\"PL\\\\\\\"))
ok2=objsuministros.altaBitacora(cadenafecha,objsuministros.getNomIdSE(idse).toString(),\\\\\\\"Suministros de Subestaciones Aportados Por CFE(Programa de Entrega)\\\\\\\",\\\\\\\"M\\\\\\\",sCambios,idlicitacion,idusuario);
ok1=objsuministros.ConsulIndvSumSubApCFEProgrPor(vids);
System.out.println(\\\\\\\"Valores de ok1: \\\\\\\"+ok1);
if(ok1 > c){
printDataMayor(req,resp);
}
if(ok1 < c){
printDataMenor(req,resp);
}
if (ok1 == c){
printData(req,resp);
}
//printData(req,resp);
}
else
printDataError(req,resp);
}
}
}
/**
* Method printData.
* @param req
* @param resp
*/
private void printData(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
resp.setContentType(\\\\\\\"text/html\\\\\\\");
PrintWriter out= new PrintWriter(resp.getOutputStream());
out.println(\\\\\\\"<html>\\\\\\\");
out.println(\\\\\\\"<head></head>\\\\\\\");
out.println(\\\\\\\"<body BGCOLOR=\\\\\\\\\\\\\\\"#abcdef\\\\\\\\\\\\\\\">\\\\\\\");
out.println(\\\\\\\"<CENTER><H1><HR WIDTH=\\\\\\\'80%\\\\\\\'><B><FONT FACE=\\\\\\\\\\\\\\\"Arial,Helvetical\\\\\\\\\\\\\\\" COLOR=\\\\\\\\\\\\\\\"#3399FF\\\\\\\\\\\\\\\">\\\\\\\" +
\\\\\\\"Los datos se han modificado Satisfactoriamente: <br>Cubriendo el 100%</FONT> <HR WIDTH=\\\\\\\'80%\\\\\\\'></H1>\\\\\\\");
out.println(\\\\\\\"<A href=\\\\\\\\\\\\\\\"/prosilWeb/suministros/ModifSuministrosSubProg.jsp\\\\\\\\\\\\\\\"> Regresar a dar otra Modificacion</A>\\\\\\\");
out.println(\\\\\\\"</CENTER></body></html>\\\\\\\");
out.close();
}
private void printDataMayor(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
resp.setContentType(\\\\\\\"text/html\\\\\\\");
PrintWriter out= new PrintWriter(resp.getOutputStream());
out.println(\\\\\\\"<html>\\\\\\\");
out.println(\\\\\\\"<head></head>\\\\\\\");
out.println(\\\\\\\"<body BGCOLOR=\\\\\\\\\\\\\\\"#abcdef\\\\\\\\\\\\\\\">\\\\\\\");
out.println(\\\\\\\"<CENTER><H1><HR WIDTH=\\\\\\\'80%\\\\\\\'><B><FONT FACE=\\\\\\\\\\\\\\\"Arial,Helvetical\\\\\\\\\\\\\\\" COLOR=\\\\\\\\\\\\\\\"#3399FF\\\\\\\\\\\\\\\">\\\\\\\" +
\\\\\\\"Los valores se guardaron satisfactoriamente, <br>Sobrepasando el 100% </FONT> <HR WIDTH=\\\\\\\'80%\\\\\\\'></H1>\\\\\\\");
//out.println(\\\\\\\"Teniedo como Suma Total: <br> Teniendo como Suma Total: String ValorTotal = request.getParameter(\\\\\\\"+ok1+\\\\\\\") if (VaorTotal != null){out.println \\\\\\\"+ok1+\\\\\\\")\\\\\\\";
out.println(\\\\\\\"<A href=\\\\\\\\\\\\\\\"javascript:history.back()\\\\\\\\\\\\\\\"> Volver a Modificar los Valores </A>\\\\\\\");
out.println(\\\\\\\"</CENTER></body></html>\\\\\\\");
out.close();
}
private void printDataMenor(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
resp.setContentType(\\\\\\\"text/html\\\\\\\");
PrintWriter out= new PrintWriter(resp.getOutputStream());
out.println(\\\\\\\"<html>\\\\\\\");
out.println(\\\\\\\"<head></head>\\\\\\\");
out.println(\\\\\\\"<body BGCOLOR=\\\\\\\\\\\\\\\"#abcdef\\\\\\\\\\\\\\\">\\\\\\\");
out.println(\\\\\\\"<CENTER><H1><HR WIDTH=\\\\\\\'80%\\\\\\\'><B><FONT FACE=\\\\\\\\\\\\\\\"Arial,Helvetical\\\\\\\\\\\\\\\" COLOR=\\\\\\\\\\\\\\\"#3399FF\\\\\\\\\\\\\\\">\\\\\\\" +
\\\\\\\"Los valores se guardaron satisfactoriamente,<br> Sin alcanzar el 100% </FONT> <HR WIDTH=\\\\\\\'80%\\\\\\\'></H1>\\\\\\\");
out.println(\\\\\\\"<A href=\\\\\\\\\\\\\\\"javascript:history.back()\\\\\\\\\\\\\\\"> Volver a Modificar los Valores </A>\\\\\\\");
out.println(\\\\\\\"</CENTER></body></html>\\\\\\\");
out.close();
}
private void printDataError(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {
resp.setContentType(\\\\\\\"text/html\\\\\\\");
PrintWriter out= new PrintWriter(resp.getOutputStream());
out.println(\\\\\\\"<html>\\\\\\\");
out.println(\\\\\\\"<head></head>\\\\\\\");
out.println(\\\\\\\"<body BGCOLOR=\\\\\\\\\\\\\\\"#abcdef\\\\\\\\\\\\\\\">\\\\\\\");
out.println(\\\\\\\"<CENTER><H1><HR WIDTH=\\\\\\\'80%\\\\\\\'><B><FONT FACE=\\\\\\\\\\\\\\\"Arial,Helvetical\\\\\\\\\\\\\\\" COLOR=\\\\\\\\\\\\\\\"#3399FF\\\\\\\\\\\\\\\">\\\\\\\" +
\\\\\\\"Los datos no pudieron ser modificados: </FONT> <HR WIDTH=\\\\\\\'80%\\\\\\\'></H1>\\\\\\\");
out.println(\\\\\\\"<A href=\\\\\\\\\\\\\\\"javascript:history.back()\\\\\\\\\\\\\\\"> Intentar Otra Vez </A>\\\\\\\");
out.println(\\\\\\\"</CENTER></body></html>\\\\\\\");
out.close();
}
public void printDataErrorLic(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType(\\\\\\\"text/html\\\\\\\");
PrintWriter out = new PrintWriter(resp.getOutputStream());
out.println(\\\\\\\"<html>\\\\\\\");
out.println(\\\\\\\"<head></head>\\\\\\\");
out.println(\\\\\\\"<body background=\\\\\\\\\\\\\\\"/prosilWeb/imagenes/fondo_1.jpg\\\\\\\\\\\\\\\">\\\\\\\");
out.println(\\\\\\\"<CENTER><H3><HR WIDTH=\\\\\\\'45%\\\\\\\'><B><FONT \\\\\\\" +
\\\\\\\"FACE=\\\\\\\\\\\\\\\"Arial,Helvetica\\\\\\\\\\\\\\\" COLOR=\\\\\\\\\\\\\\\"#3399FF\\\\\\\\\\\\\\\">\\\\\\\" +
\\\\\\\"No se pudo realizar la Transacción Correctamente: <BR><BR>Debido a \\\\\\\"+
\\\\\\\"que la Licitación se encuentra en su Versión Final\\\\\\\"+
\\\\\\\"<BR><BR>y es de Solo lectura, solo son válidas las Consultas <BR><BR>\\\\\\\"+
\\\\\\\"No intente realizar algun actividad diferente</FONT><HR WIDTH=\\\\\\\'45%\\\\\\\'></H1>\\\\\\\");
out.println(\\\\\\\"<A href=\\\\\\\\\\\\\\\"/prosilWeb/suministros/ModifSuministrosSubProg.jsp\\\\\\\\\\\\\\\"> Intentar Otra Vez </A>\\\\\\\");
out.println(\\\\\\\"</CENTER></body></html>\\\\\\\");
out.close();
}
/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
}
}