how to display?

Ads

 
 
 

Share on Google+Share on Google+

maithri
how to display?
0 Answer(s)      6 years and 2 months ago
Posted in : JSP-Servlet

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
Ads
View Answers
Ads









Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads