Recebendo varivael via request e setando campo text

4 respostas
crisdoconquista

Boa noite amigos, no programa abaixo estou pegando os valores do campos via request, até aí tranquilo, agora como pegar esse valor e setar novamente um campo em html?

[/code]<%

String txtSigla = request.getParameter(“txtsigla”);

String txtEstado = request.getParameter(“txtname”);

%>

<%@page contentType=“text/html” pageEncoding=“UTF-8”%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>Tabela de Estados</title>
</head>
<body>

&lt;form action="" method="POST"&gt;
       &lt;div&gt;
           &lt;h1&gt;Tabela de Estados&lt;/h1&gt;  
            Sigla:&lt;input type="text" size="2" maxlength="2"
                         name="txtsigla" id="txtsigla" /&gt;
            &lt;input type="submit"  value="Localizar"
                   name="btnLocalizar"  id="btnLocalizar" /&gt;
            
            <br>
            Nome:&lt;input type="text" size="50" maxlength="50"
                        name="txtname" id="txtname" /&gt;
            <br><br>
            &lt;input type="submit"  value="Inserir"
                   name="btnInsert"  id="btnInsert" /&gt;
    &lt;/div&gt;     
    &lt;/form&gt;
    
    <br><br>
    <a >Menu</a> 
&lt;/body&gt;

</html>

Tenho o campo input de name=txtname, qdo dou submit consigo pegar esse valor, e quero saber como coloca-lo novamente no campo input.

4 Respostas

romarcio

Coloca o seu código entre as tags CODE.

Dai faz assim:

request.getSession().setAttribute("txtname", "JOAO");

e no input

Nome:&lt;input type="text" size="50" maxlength="50" name="txtname" id="txtname" value="${txtname}" /&gt;

A

cara,

faz o seguinte

<input type="text" size="2" maxlength="2" name="txtsigla" id="txtsigla" value="<%= request.getParameter("txtsigla") %>"/>

t+

crisdoconquista

vou tentar, e depois post o resultado.

Obrigado!

crisdoconquista

Muito obrigado, usando a sugestao do romarcio consegui resolver. A outa soluçao tb funciona porém o campo vem preenchido por default como null.

Criado 22 de outubro de 2011
Ultima resposta 22 de out. de 2011
Respostas 4
Participantes 3