2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by __avd
0

Here is a sample program.

sample.jsp

<%@ page language="java"%>

<%
    String cmd=request.getParameter("cmd");
    String search=request.getParameter("cmd");
    String result="No Result";
    if(cmd==null) cmd="";
    if(cmd.equals("Submit")) {
              String sql="select * from table where colname like '%" + search + "%'";

              .... Sql Api ...
              ....
              Connection cn = ......
              Statement st=cn.createStatement();
              ResultSet rs=st.executeQuery(sql);
 
              while(rs.next()) {
                   result=result + "<br/>" +   rs.getString(1)  +  " " + rs.getString(2));             
                }

              rs.close();
              st.close();
              cn.close();
     }  
%>
    <html>
           <head><title>Sample</title></head>
            <body>
                 <form method="post" action="sample.jsp">
                       Search <input type="text" name="search"/> 
                                   <input type="submit" name="cmd" value="Submit"/>
                 </form>
                <hr/>
                 <%=res%>
           </body>
    </html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.