How to return an imported value from one JSP page to another?

Asked

Viewed 821 times

3

I have two JSP pages: in one it checks a condition of client links, if it has no link, it enters a function that calls another JSP to import client data.

He even imports the data but, when he returns the JSP that called him he does not immediately bring the data, I have to type again the client to see his data!

I want to know if there is any way when import and return to the previous JSP it already bring the data and fill in the fields automatically?

Follows part of the JSP code that calls the other JSP to import data

function setar(chave, campo, valorchave, valorcampo, vinculo) {
    if (vinculo == 'N'){
        document.getElementById(chave).value = valorchave;
        document.getElementById(campo).value = valorcampo;
        x.innerHTML = "";
        hide();

        if(campo=="nome")         {
           var jsquery = "<%= query%>";
           //Tira o paciente e coloca o escolhido
           jsquery = replaceParameter(jsquery, "codcli", valorchave);
           document.getElementById("frmcadastrar").action = displayPopup("ativapaciente.jsp?"+jsquery+ "&emp="+empresa,"ativapac",300,500);

        }
    }else{
        document.getElementById(chave).value = valorchave;
        document.getElementById(campo).value = valorcampo;
        x.innerHTML = "";
        hide();

        if(campo=="nome") {
            var jsquery = "<%= query%>";
            jsquery = replaceParameter(jsquery, "codcli",valorchave);
            document.getElementById("frmcadastrar").action = "detalheagenda.jsp?"+jsquery;
            document.getElementById("frmcadastrar").submit();
        }
    }
}

and here part of JSP that imports the data and returns to what called

function gravarPacienteAtivo(){
    if(document.getElementById("cpf").value != "" || document.getElementById("carteira").value != "" || document.getElementById("fone").value != "" ) {                                                               
        var salvar = document.getElementById("frmcadastrar");
        salvar.action+="?codcli="+cod_pac+"&cod_empresa="+empresa;
        salvar.submit();
    }else
        alert("Escolha e preencha uma das informações necessárias.");
    }
}

//função retorna a janela
function iniciar() {          
    if(inf == "1"){ 
        alert("Paciente ativado com sucesso.");
        //Abri a página que abriu esse jsp
        self.close();
        window.opener.location.reload(true);

    } else
        inicio();
    }
}
  • Question: you have tried to implement the doPost and doGet methods. You can pass the values through Httpservletrequest.

  • I didn’t try, you can explain to me how to do?

  • Maybe this FINSLAB link can help you do it.. I’m not sure that’s the solution to your problem anymore in any case see... http://finslab.com/negocios-e-work/artigo-1168.html

  • Dude, this is not JSP is javascript! You want to bring data from your JSP to Javascript?

  • Oops, my good man. Have you tried to pass this information through even classes, a Bean, where you would already do an ajax function to validate and redirect to another screen (or what would I do, a modal on the same screen, depending on the amount of information)? In my opinion, it would be the most appropriate form, or at least more appropriate than the current one. If I’m wrong, could you describe your information flow better, please? I hope I’ve helped.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.