0

I'm trying to assign the selected value of a dropdown list to a java variable.

The values which the options contain are fetched from the database, but I don't have any clue how to do this.

Say for example I have this:

<html>
<head>
</head>
<body>
<select>
  <option>fetched from database<option>
</select>
<%  //The java code
String select=//how can i get selected value here
%>
</body>
</html>
Graham
  • 7,431
  • 18
  • 59
  • 84
  • You cannot. Learn about JSP/Servlet lifecycle. You have to have a `
    `, and a server-side code (an another JSP, or - preferably - a servlet) to process its submission. See e.g. https://www.codejava.net/java-ee/servlet/handling-html-form-data-with-java-servlet or http://candidjava.com/tutorial/servlet-form-example/
    – Jozef Chocholacek Jan 16 '19 at 07:05
  • Possible duplicate of [How to transfer data from JSP to servlet when submitting HTML form](https://stackoverflow.com/questions/4971877/how-to-transfer-data-from-jsp-to-servlet-when-submitting-html-form) – Jozef Chocholacek Jan 16 '19 at 07:06
  • Thank you so much you guys answer my question. This is only an example what i want to do. Actually i have a jsp page in that i have select box and the value that select box carry is fetched from the database. What i want that if user select any value from select box than according to that particular value data would be fetch in the html table – Talal Wasif Jan 17 '19 at 09:49

0 Answers0