Sessao

1 resposta
D

Fala galera, to precisando de uma ajuda ai...

tipow..eu to abrindo uma sessao onde logo após executar minhas funções gostaria que ela fechasse , pois quando entro na pagina ao invés de ela estar vazia ela entra com a ultima consulta realizada!!

acho que teria de haver um jeito de tirar esse pesq da sessao..

bom, vou postar o codigo...
se puderem me ajudem!

<%
Object pesq[] = (Object[])session.getAttribute("pesq");
//String rs = (pesq==null?"":(String)pesq[1]);
String rp = (pesq==null?"10":(String)pesq[2]);
String pg = (pesq==null?"1":(String)pesq[3]);
String tabela = (pesq==null?"":(String)pesq[0]);
String crit1 = (pesq==null?"":(String)pesq[4]);
String chave1 = (pesq==null?"":(String)pesq[5]);
String crit2 = (pesq==null?"":(String)pesq[6]);
String chave2 = (pesq==null?"":(String)pesq[7]);
String crit3 = (pesq==null?"":(String)pesq[8]);
String chave3 = (pesq==null?"":(String)pesq[9]);
String crit4 = (pesq==null?"":(String)pesq[10]);
String chave4 = (pesq==null?"":(String)pesq[11]);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Consultas</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/pc/jsp/comercial.css" rel="stylesheet" type="text/css">

<script language=javascript>
function inicio(){
	document.frmPesquisa.numPagina.value = 1;
	document.frmPesquisa.submit();
}
function avancar(){
	var n=0;
	n = document.frmPesquisa.numPagina.value;
	document.frmPesquisa.numPagina.value = parseInt(n)+1;
	document.frmPesquisa.submit();
}
function voltar(){
	var n=0;
	n = document.frmPesquisa.numPagina.value;
	document.frmPesquisa.numPagina.value = n-1;
	document.frmPesquisa.submit();
}
function fim(){
	document.forms[0].numPagina.value = document.forms[0].totalPagina.value;
	document.forms[0].submit();
	
}


// begin
var info = new Array(
	" *---|---",
    "Empresa*Nome|Relacionamento|Telefone|CNPJ",
    "Empreendimento*Nome|Carteira|Estado|Previsão|Cidade",
    "Contato*Nome|Telefone|Cargo|Religião"
);

/******************************************************************************************************/

function stringSplit ( string, delimiter ) { 
    if ( string == null || string == "" ) { 
        return null; 
    } else if ( string.split != null ) { 
        return string.split ( delimiter ); 
    } else { 
        var ar = new Array(); 
        var i = 0; 
        var start = 0; 
        while( start >= 0 && start < string.length ) { 
             var end = string.indexOf ( delimiter, start ) ; 
             if( end >= 0 ) { 
                 ar[i++] = string.substring ( start, end ); 
                 start = end+1; 
             } else { 
                 ar[i++] = string.substring ( start, string.length ); 
                 start = -1; 
             } 
        } 
        return ar; 
    } 
} 
/******************************************************************************************************/

var menu1 = new Array();
var menu2 = new Array();

/******************************************************************************************************/
function createMenus () {

    for ( var i=0; i < info.length; i++ ) {
        menu1[i] = stringSplit ( info[i], '*' );
        menu2[i] = stringSplit ( menu1[i][1], '|' );
    }

    var pesquisa = document.frmPesquisa.main;
    var crit1 = document.frmPesquisa.crit1;
    var crit2 = document.frmPesquisa.crit2;    
    var crit3 = document.frmPesquisa.crit3;    
    var crit4 = document.frmPesquisa.crit4;
    
    

    pesquisa.length = menu1.length;
    crit1.length = menu2[0].length; 
    for ( var i=0; i < menu1.length; i++ ) {
         pesquisa.options[i].value  = menu1[i][0];
         pesquisa.options[i].text   = menu1[i][0];
    }
    document.frmPesquisa.main.selected = 0;
    for (var x=0; x < menu2[0].length; x++) {
         crit1.options[x].text = menu2[0][x];
         crit2.options[x].text = menu2[0][x];
         crit3.options[x].text = menu2[0][x];
         crit4.options[x].text = menu2[0][x];

         crit1.options[x].value = menu2[0][x];
         crit2.options[x].value = menu2[0][x];
         crit3.options[x].value = menu2[0][x];
         crit4.options[x].value = menu2[0][x];   
                                                  
    }         
    document.frmPesquisa.crit1.selected = 0;
    document.frmPesquisa.crit2.selected = 0;
    document.frmPesquisa.crit3.selected = 0;
    document.frmPesquisa.crit4.selected = 0;
                   
}

/******************************************************************************************************/

function updateMenus ( what ) {
    var sel = what.selectedIndex;

    if ( sel >= 0 && sel < menu1.length ) 
        var temp = menu2[sel];
    else
        var temp = new Array ();
    
    what.form.crit1.length = temp.length;
    what.form.crit2.length = temp.length;
    what.form.crit3.length = temp.length;
    what.form.crit4.length = temp.length;

    for ( var i = 0; i < temp.length; i++ ) {
        what.form.crit1.options[i].text  = temp[i];
        what.form.crit2.options[i].text  = temp[i];
        what.form.crit3.options[i].text  = temp[i];                
        what.form.crit4.options[i].text  = temp[i];

                
        what.form.crit1.options[i].value = temp[i];
        what.form.crit2.options[i].value = temp[i];
        what.form.crit3.options[i].value = temp[i];
        what.form.crit4.options[i].value = temp[i];

    }
    what.form.crit1.selected=0;
    what.form.crit2.selected=0;    
    what.form.crit3.selected=0;    
    what.form.crit4.selected=0;    
}
<!--end of hiding -->
</script>

</head>

<body leftmargin="0" topmargin="10" onLoad="createMenus()">
<form name="frmPesquisa" method="POST" action="/pc/pcPesquisa" target="pesqBottomFrame">
		                 <input type="hidden" class=borda_cadastro size=5 name="totalPagina" readOnly="True" value="<%=session.getAttribute("totalPagina")==null?"":(String)session.getAttribute("totalPagina")%>">
		                 <input type="hidden" class=borda_cadastro size=5 name="numPagina" readOnly="True" value="<%=pg%>">
<table border="0" cellpadding="0" cellspacing="0" width="600" border="fixed">
  <tr>
    <td width="100%">
      <table border="0" cellpadding="0" cellspacing="0" width="600">
        <tr>
          <td width="25%"><font face="Verdana, Arial, Helvetica, sans-serif" size=2>Pesquisa por:</font></td>
          <td width="25%"><select name="main" size="1" onChange="updateMenus(this)">
                	    <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<option>
						<option>
                      </select> </td>
          <td width="10%"><input class=borda_cadastro size=4 name="rp" value="<%=rp%>"></td>
          <td width="40%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Resultado
                    por P&aacute;gina </font></td>
        </tr>
      </table>
      <table border="0" cellpadding="0" cellspacing="0" width="600">
        <tr>
          <td width="16%"><p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Crit&eacute;rio:</font></p></td>
          <td width="16%"><select name="crit1" size="1">
                        <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<option>
						<option>
                      </select> </td>
          <td width="17%"><input class=borda_cadastro size=15 name=txt1 value="<%=chave1%>"></td>
          <td width="17%"><p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Crit&eacute;rio:</font></p></td>
          <td width="17%"><select name="crit3" size="1" id="select">
                      <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <option>
                      <option>
                      </select></td>
          <td width="17%"><input class=borda_cadastro size=15 name=txt3 value="<%=chave3%>"></td>
        </tr>
        <tr>
          <td width="16%"><p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Crit&eacute;rio:</font></p></td>
          <td width="16%"><select name="crit2" size="1" id="crit2">
                	    <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<option>
						<option>
                      </select></td>
          <td width="17%"><input class=borda_cadastro size=15 name=txt2 value="<%=chave2%>"></td>
          <td width="17%"><p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size=1>Crit&eacute;rio:</font></p></td>
          <td width="17%"><select name="crit4" size="1" id="select2">
                      <option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <option>
                      <option>
                      </select></td>
          <td width="17%"><input class=borda_cadastro size=15 name=txt4 value="<%=chave4%>"></td>
        </tr>
      </table>
      <table border="0" cellpadding="0" cellspacing="0" width="600" border="fixed">
        <tr>
          <td width="50%" HEIGHT="40">
            <p align="center"><input class=borda_cadastro type=submit value=Consultar name=bConsultar></td>
          <td width="50%" HEIGHT="40">
            <p align="center">
<map name="Map">
  <area coords="-5,-2,12,21" href="#" onClick="javaScript:inicio()">
  <area coords="27,-2,35,21" href="#" onClick="javaScript:avancar()">
  <area coords="15,-5,24,20" href="#" onClick="javaScript:voltar()">
  <area coords="38,-2,54,19" href="#" onClick="javaScript:fim()">
</map>
<img src="/pc/images/setas.gif" width="53" height="20" border="0" usemap="#Map" href="setas4">	
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</form>
</body>
</html>

1 Resposta

Rafael_Steil

Vc esta usando JSP neh? Entao coloque no request (request.setAttribute() ) ao inves de colocar na session.

Rafael

Criado 15 de março de 2005
Ultima resposta 15 de mar. de 2005
Respostas 1
Participantes 2