将JavaScript值分配给Scriptlet

时间:2011-12-07 01:08:38

标签: javascript variables scriptlet

任何人都可以告诉我如何将java脚本变量的内容分配给scriptlet变量。 这是我的代码:

    function getComment(location){
    <%
    try{
        Class.forName(driver).newInstance();
        con = DriverManager.getConnection(url+db,userName,password);
        String locate=//i want here to assign the value of location;
        String query = "select * from comments where location='"+locate+"'"  ;
        st = con.createStatement();
        ResultSet rs = st.executeQuery(query);%>

    <% int i=0;
    while(rs.next()){%>
    var comment = comment + "<BR>" + <%=rs.getString("comments")%>
    <% i++; }
    }
    catch(Exception e){
    e.printStackTrace();}
    %>
    return comment;
    }

0 个答案:

没有答案