2012-03-29 51 views

答えて

0

jspから選択したアイテムの値を取得します。サーブレットでこのコードを書いてください:

<% 
String selectedValue=request.getParameter("lang"); 
out.println("Selected Value is: "+selectedValue); 

Connection con = null; 
    String url = "jdbc:mysql://localhost:3306/"; 
    String db = "jdbctutorial"; 
    String driver = "com.mysql.jdbc.Driver"; 
    try{ 
    Class.forName(driver); 
    con = DriverManager.getConnection(url+db,"root","root"); 
    try{ 
    Statement st = con.createStatement(); 
    int val = st.executeUpdate("INSERT employee VALUES("'"+"selectedValue"+"'"s); 
    System.out.println("1 row affected"); 
    } 
    catch (SQLException s){ 
    System.out.println("SQL statement is not executed!"); 
    } 

%> 
+0

ありがとうございました。 – Vetha

関連する問題