about jquery and jsp

Adwait Chitaley
Adwait Chitaley used Ask the Experts™
on
i have to modify functinality i want to send the word which type the user to the text.jsp and call the query on that word so that i get filter record

how can i do please help me out.......
this is welcomestruts.jsp
 
 
<html>
<head>
  <script src="jquery-latest.js"></script>
  <link rel="stylesheet" href="main.css" type="text/css" />
  <link rel="stylesheet" href="jquery.autocomplete.css" type="text/css" />
   
 
  <script type="text/javascript" src="jquery.autocomplete.js"></script>
  <script>
     $(document).ready(function(){
    var data = "text.jsp";
     
    $("#example").autocomplete(data);
     
    
  });
  
     
  </script>
  
</head>
<body>
  API Reference: <input id="example" /> (try "p" or "a")
</body>
</html>
 
 
_______________________________________________________________________
 
this is my text.jsp 
 
 
<%@page contentType="text/html" pageEncoding="UTF-8" language="java"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.ArrayList" %>
 
 
<%
Connection con = null;
Statement st = null;
ResultSet rs=null;
ResultSet rs1=null;
int count=0;
%>
 
<%
    try {
     
        Class.forName ("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection("jdbc:mysql:///ashu_db","root","mysql");
        st = con.createStatement();
        
        
//         String query1="select count(*) from user";
    //      System.out.println("Count  query: "+query1); 
        
//         rs1=st.executeQuery(query1);
//          while(rs1!=null && rs1.next()){ 
//               count=rs1.getInt(1); 
//              }
       
          String query = " select * from user";
          System.out.println("Select query: "+query); 
         rs=st.executeQuery(query);
        
             while(rs!=null && rs.next())
             {   
                   rs.getInt("userID"); 
                   out.println(rs.getString("userName"));
             } 
      
    } catch (Exception e){
        System.out.println("Erorr Message"+e.getMessage());
    }	  
 
%>
 
----------------------------------------------------------

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Try something like this :

 
<%@page contentType="text/html" pageEncoding="UTF-8" language="java"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.ArrayList" %>
 
 
<%
Connection con = null;
Statement st = null;
ResultSet rs=null;
ResultSet rs1=null;
int count=0;
String param = request.getParameter("q");
%>
 
<%
    try {
     
        Class.forName ("com.mysql.jdbc.Driver").newInstance();
        con = DriverManager.getConnection("jdbc:mysql:///ashu_db","root","mysql");
        st = con.createStatement();
        
        
//         String query1="select count(*) from user";
    //      System.out.println("Count  query: "+query1); 
        
//         rs1=st.executeQuery(query1);
//          while(rs1!=null && rs1.next()){ 
//               count=rs1.getInt(1); 
//              }
       
          String query = " select * from user where userName LIKE '%"+ param +"%'";
          System.out.println("Select query: "+query); 
         rs=st.executeQuery(query);
        
             while(rs!=null && rs.next())
             {   
                   rs.getInt("userID"); 
                   out.println(rs.getString("userName"));
             } 
      
    } catch (Exception e){
        System.out.println("Erorr Message"+e.getMessage());
    }     
 
%>

Open in new window

Author

Commented:
Thank You very much Sir

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial