[Resolvido] Não consigo pegar valor do parametro da request

1 resposta
A
Li em vários lugares que para pegar valores de metodos POST ou GET basta usar o .getParameter(nome) mas ele só me retorna nulo... segue a minha pagina web:
<form name="myform" enctype="multipart/form-data" method="post" onsubmit="return validate();" action="ControllerServlet">
<h3>${mensagem}</h3>
<input type="hidden" name="cmd" value="lerXML"/><br>
<table align="center">
	<thead>
		<tr valign="middle">
			<th colspan="2" align="center"> Procure seu XML </th>
		</tr>					
	</thead>
	<tr>
		<td style="width: 269px; ">
			<input name="xml" type="file" accept="xml" id="xml" class="dados" style="font-size: 12px; height: 20px; width: 269px">
		</td>
		<td style="width: 143px; ">
			<input type="submit" id="upld" name="upload" value="Fazer Upload" style="font-size: 12px; height: 24px" align="middle"> 
		</td>			
</table></form>
Eu faço um upload e tento pegar o valor do meu input que está hidden.. mas ele me retorna nulo!
System.out.println(request.getParameter("cmd"));
alguem sabe pq??

detalhe que havia esquecido: quando eu mudo o metodo para GET ele consegue pegar o parametro com sucesso

1 Resposta

A
anderson_lp789:
Li em vários lugares que para pegar valores de metodos POST ou GET basta usar o .getParameter(nome) mas ele só me retorna nulo... segue a minha pagina web:
<form name="myform" enctype="multipart/form-data" method="post" onsubmit="return validate();" action="ControllerServlet">
<h3>${mensagem}</h3>
<input type="hidden" name="cmd" value="lerXML"/><br>
<table align="center">
	<thead>
		<tr valign="middle">
			<th colspan="2" align="center"> Procure seu XML </th>
		</tr>					
	</thead>
	<tr>
		<td style="width: 269px; ">
			<input name="xml" type="file" accept="xml" id="xml" class="dados" style="font-size: 12px; height: 20px; width: 269px">
		</td>
		<td style="width: 143px; ">
			<input type="submit" id="upld" name="upload" value="Fazer Upload" style="font-size: 12px; height: 24px" align="middle"> 
		</td>			
</table></form>
Eu faço um upload e tento pegar o valor do meu input que está hidden.. mas ele me retorna nulo!
System.out.println(request.getParameter("cmd"));
alguem sabe pq??

detalhe que havia esquecido: quando eu mudo o metodo para GET ele consegue pegar o parametro com sucesso

consegui com a propria API fileupload do commons da apache:
if (item.isFormField()) {  
                        if (item.getFieldName().equals("cmd"))  
                        {  
                        	teste = item.getString();
                        	System.out.println(teste);
                        }
                        
                    }  
                    else {  
//eh um arquivo binario }
Criado 2 de outubro de 2010
Ultima resposta 3 de out. de 2010
Respostas 1
Participantes 1