protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { JDBC jdbc = new JDBC(); PrintWriter pw = response.getWriter(); LinkedList<String> type = jdbc.getDataFromDBType(); pw.println("<html lang="en">\n" + "<head>\n" + " <meta charset="UTF-8">\n" + " <title>Title</title>\n" + "</head>\n" + "<body>\n" + "<select name=Teleph id=Teleph>"); for (Inf inf1 : inf) { pw.println( "<option value="+inf1.getTelephone_email()+">" + inf1.getTelephone_email() + "</option>"); } pw.println("</select>\n"); response.getWriter().write(""+request.getParameter("Teleph")); } 

I have a code. here I tried to read the selected value from select name = Teleph. but the result is null. Tell me how this can be implemented.

  • How do you read the value? - Mikhail Vaysman
  • @Mikhail "request.getParameter (" Teleph ")" - cccheshi
  • You need to add either a form or js code to your page. Pot here you can read in detail how to work with forms in servlets tutorialspoint.com/servlets/servlets-form-data.htm - Mikhail Vaysman
  • @MikhailVaysman I added, but it did not help me - cccheshi
  • @MikhailVaysman; As I understood, the form is used with input, but with the select form it is not necessary. in select, the value is obtained through the name of the select'a - cccheshi

0