By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

How to pass Javascript Value to a Jsp

P: 14
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............



Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script type="text/javascript" src="gears_init.js"></script>
  3. <script type="text/javascript">
  4. var db = google.gears.factory.create('beta.database');
  5. db.open('database-demo');
  6. var rs = db.execute('select * from ntech');
  7. while (rs.isValidRow()) {
  8. alert(rs.field(0)+" "+rs.field(1));
  9. var name=rs.field(0);
  10. var address= rs.field(1);
  11.   alert(name);
  12.   alert(address);
  13.  
  14.  
  15. <%
  16.    Connection conn = null;
  17.    ResultSet rs = null;
  18.    String result="";
  19.  
  20.    PreparedStatement stmt = null;
  21.  
  22.  
  23.        try {                                     
  24.                        conn = Utilities.getDbConnection();
  25.                     stmt  = conn.prepareStatement("insert into test (name,address) values (rs.field(0),rs.field(1)) "); 
  26.  

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

any help will be appreciated highly,
with regards,
Creeds
Jul 7 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
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.
Jul 7 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.