How to pass Javascript Value to a Jsp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • creeds
    New Member
    • Feb 2008
    • 14

    How to pass Javascript Value to a Jsp

    Hello everybody,
    As i get a value from javascript , i am in need of posting that to a jsp codes,
    my code snippet is as............



    Code:
    <html>
    <script type="text/javascript" src="gears_init.js"></script>
    <script type="text/javascript">
    var db = google.gears.factory.create('beta.database');
    db.open('database-demo');
    var rs = db.execute('select * from ntech');
    while (rs.isValidRow()) {
    alert(rs.field(0)+" "+rs.field(1));
    var name=rs.field(0);
    var address= rs.field(1);
      alert(name);
      alert(address);
      
      
    <%
       Connection conn = null;
       ResultSet rs = null;
       String result="";
       
       PreparedStatement stmt = null;
     
    
           try {                             		
    	   				conn = Utilities.getDbConnection();
                    	stmt  = conn.prepareStatement("insert into test (name,address) values (rs.field(0),rs.field(1)) ");

    her i need to pass the values as rs.filed(0) and (1)

    any help will be appreciated highly,
    with regards,
    Creeds
    Last edited by acoder; Jul 7 '08, 11:47 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    JavaScript is client-side and JSP is server-side. To pass the JavaScript value, use a form to post the values. You can set the values of hidden form elements. If you need to do this without reloading/unloading the page, use Ajax.

    Comment

    Working...