i have a form which contains dropdown list. i have to take the values to another jsp page and perform the calculation on the database which i have earlier using the values of the selected dropdown list and there must not be any change in the database.. i have to display the database as it is and the new function value in the new jsp page.. im in the middle of the project and stuck with it.. plz can any one help me.. Thank you in advance
Here is a simple example which may be helpful for you. The given code allow the user to select from drowndown list and insert that value into database.
<html> <form method="post"> Select Programming Language: <select name="lang"> <option value="C/C++">C/C++</option> <option value="C#">C#</option> <option value="Java">Java</option> <option value="Perl">Perl</option> <option value="Python">Python</option> </select><br> <input type="submit" value="Submit"><br> </form> </html>
<%@page import="java.sql.*" <% String selectedValue=request.getParameter("lang"); out.println("Selected Value is: "+selectedValue); Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); Statement st=con.createStatement(); int i=st.executeUpdate("insert into data(language) values('"+selectedValue+"')"); out.println("Data is inserted successfully"); %>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.