Retrieve which data has been selected from a select of a jsp and retrieve it in a servlet

0
<select name="categorias">
 <option selected>SELECCIONE UNA CATEGORIA</option>
 <option value="1" >CIENCIAS DE LA COMPUTACIÓN</option>
 <option value="2" >QUÍMICA E INGENIERÍA DEL PETRÓLEO</option>
 <option value="3" >INGENIERÍA AMBIENTAL</option>
 <option value="4" >INGENIERÍA MECÁNICA</option>
 <option value="5" >INGENIERÍA CIVIL</option>
 <option value="6" >ELECTRÓNICA</option>
</select><br>

I want to know how to recover the value that the user selects and pass it to a servlet

    
asked by Victor Manuel Chan Cauich 15.12.2018 в 20:29
source

1 answer

0

Hello, so you can retrieve the form data in the servlet

String categoria_seleccionada = request.getParameter("categorias"); 

where "categories" must be equal to the name of your combobox of your jsp or any other html component as inputs defined as name="comboboxname". and so you can send data to the jsp is the next one

 String mensaje= "hello";
 request.setAttribute("saludo",mensaje);

Rebuild in your jsp and print it

 <%String mensaje =(String)request.getAttribute("saludo");%>
<p><%=mensaje%> </p>
    
answered by 16.12.2018 в 01:43