how to display?

how to display?

I have to write a code for searcing books in library and i have written but it is not displaying the result.I don't know where i have gone wrong.Also i want to know if there is any better idea then this and what type of validations i can give.I have written code as shown below.

search.html

<body>

<form name="search" action="http://localhost:8080/examples/jsp/searchbook.jsp" method="post">
<table align="center">
<tr> <td> Select any field </td> <td> <select name="keyfield" > <option> title</option> <option> author </option> <option> category </option>    <option>pub_year</option> </select> </td> </tr>
<tr> <td> Enter the keyword: </td> <td><input type="text" name="keyword" /> </td> </tr>
<tr> <td> <input type="submit" value="Search" /> </td> <td> <input type="reset" value="reset" /></td></tr>
</table>
</form>

</body>
<strong>search.jsp</strong>

<body>
<table border=2>
<tr> <th>acc<em>no  </th><th>title</th>  <th>category</th><th> no</em>of<em>copies </th>  <th> edition </th>    <th> pub</em>year</th>  <th> price </th>  </tr>
&lt;%
   String keyfield=request.getParameter("keyfield");
   String keyword=request.getParameter("keyword");
   try
    {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:dms"," smartlib","smartlib");
    Statement stmt1=con.createStatement();
    ResultSet rs=stmt1.executeQuery("SELECT a.accno,a.title,a.category,a.no_of_copies,b.edition,c.pub_year,d.price from book_det a,edition b,publication c,price d where (a.accno=b.accno and a.accno=c.accno and a.accno=d.accno) and ('"+keyfield+"'='"+keyword+"')");
    while (rs.next())
    {
        %&gt;
         &lt;tr&gt; &lt;td&gt; &lt;%=rs.getString(1)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=rs.getString(2)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=rs.getString(3)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=rs.getString(4)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=rs.getString(5)%&gt; &lt;/td&gt; &lt;td&gt; &lt;%=rs.getString(6)%&gt; &lt;td&gt; &lt;%=rs.getString(7)%&gt; &lt;/td&gt; &lt;/tr&gt;

     &lt;%}
     rs.close();
     stmt1.close();
     con.close();
}
catch(ClassNotFoundException cnfe){out.println(cnfe.getMessage());}
catch(java.sql.SQLException sqle){out.println(sqle.getMessage());}
     %&gt;

</body>
</html>

Thank u in advance
View Answers









Related Tutorials/Questions & Answers:
ModuleNotFoundError: No module named 'displays'
ModuleNotFoundError: No module named 'displays'
Advertisements
ModuleNotFoundError: No module named 'displays'
ModuleNotFoundError: No module named 'rpi-displays'
jtable displays search results
Flex - Call JavaScript Function And Open a Popup Window that Displays Data
Write a program in JAVA which accepts a sentence & displays the longest word in the sentence alongn with it length of the word.
Q6 Write a java applet that displays 9 squares, one below the other. Every third square must be filled in black?
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse
How to display date in JSP?
MySQL by
How to make Spring web Login form?
Calculation Example
Comparing XML with HTML
Combobox in HTML
JavaScript for beginners
TextArea Frame in Java
SQL OR Operators
How to display date in JSP?
Flex Accordion Menu
How to display gridview details to labels dynamically?
How to get current logged in Windows username? - Struts
how to write this program
List Control with Data Provider
Tomahawk messages tag
how to write tis java programming - Java Beginners
Display current time using jQuery & JSP
Java How to Program
Java error cannot find symbol
Password Field in HTML
really need help on how to write this program plz some 1 help out. - Java Beginners
jsp :how to edit table of data displayed using jsp when clicked on edit button
How to store values in a database using JSTL? - JSP-Servlet
How to make a servlet to automatically call another servlet at some time instant.
How to convert String to int in Java
How to convert String to int in Java
How to convert String to int in Java
How to convert String to int in Java
How to create file from input values in Jframe ?
how to make following pyramid using loop
Displaying System Files in JTree
jaret timebars
How to display image in Swing?
How to display image in Swing?
How to format number in Java?
How to create Link in SWT
how to play audio track in java applat
CAP - Code Analysis Plugin
Round gradient Paint Example
Java Compilation error and how to continue from this - Java Beginners

Ads