Avinash_11 0 Newbie Poster

the code below is working, but it is displaying only one image in a blank page where there is no css
I want it to display all the image in a table.
please help me...

<%@page import="com.sun.javafx.tk.Toolkit"%>
<%@page import="java.awt.Image"%>
<%@page import="javax.swing.ImageIcon"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>   
    <%@page import ="java.sql.*" %>
    <%@page import="java.io.*" %>
    <%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/product.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Product</title>
</head>
<body>
    <div class="nav">
    <div id="contactBox">
    <form method="post" action="showSearch.jsp">
    <input type="text" name="searching" id="search"/><input type="submit" name="look" value="Search" id="searchButton"/>
    </form>
    </div>
    <img src="indica.PNG" alt="indica" width="500" height="90" id="indi"/>
    <div id="single">
         <ul>
            <li><a href="HomePage.jsp" class="home">HOME</a></li>
            <li><a href="Product.jsp" class="product">PRODUCT</a></li>
            <li><a href="" class="contact">CONTACT</a></li>
            <li><a href="" class="cart">CART</a></li>
            <li><a href="login.jsp" class="login">LOGIN</a></li>
         </ul> 
     </div>  
     </div>
     <div id="selection">
        <form method="post" action="Product.jsp">
         <img src="name.PNG" alt="indica" width="270" height="100" id="brand"/>
             <div id="buttons">
                 <input type="submit" value="Men" name="btn" class="but"/><br>
                 <input type="submit" value="Women" name="btn" class="but"/><br>
                 <input type="submit" value="Brand" name="btn" class="but"/><br>
                 <input type="submit" value="CashManager" name="btn" class="but"/><br>
                 <input type="submit" value="Trend" name="btn" class="but"/><br>
                 <input type="submit" value="Sale" name="btn" class="but"/><br>
                 <input type="hidden" name="submitted" value="true"/>
             </div>

         </form>
     </div>
     <div id="wall">

   <%
        String url="jdbc:mySql://localhost/indica";
        String login="root";
        String password="";
        Class.forName("com.mysql.jdbc.Driver");
        Connection con=DriverManager.getConnection(url,login,password);
        Boolean submitted=Boolean.parseBoolean(request.getParameter("submitted"));
        if (submitted){
            String type=request.getParameter("btn");
            ResultSet rs = null;
            ResultSet res =null;
            PreparedStatement pStart = null;
            PreparedStatement pShow = null;

            //OutputStream img;
            Blob imgs ;
            byte[] imgDatas = null ;
            byte[] imgData = null ;
            try{
                pStart = con.prepareStatement("SELECT * FROM sunglasses WHERE Gender=?");
                pStart.setString(1, type);
                rs=pStart.executeQuery();
                ArrayList id=new ArrayList();
                while(rs.next()){
                    String strprodvalue = rs.getString("id");
                    id.add(strprodvalue);
                }

                for (int i = 0; i < id.size(); i++) {
                    String ids=(String)id.get(i);
                    Blob image = null;
                    pShow = con.prepareStatement("SELECT * FROM sunglasses WHERE id=?");
                    pShow.setString(1, ids);
                    res=pShow.executeQuery();
                        while(res.next()){
                            Blob bl =res.getBlob("image");
                            byte[] pict = bl.getBytes(1,(int)bl.length());
                            response.setHeader("expires", "0");
                            response.setContentType("image/png");
                            OutputStream o = response.getOutputStream();

                    %>
                    <TABLE BORDER="1">
    <TR>
    <TH>picture</TH>
    </TR>
    <TR>

    <td>Image</td><td><%o.write(pict); %></td>
        <%o.flush();
        o.close();%>

    </TR>
    </TABLE>
    <BR>
                    <%
                    }
                }
            }catch(Exception e){
                e.printStackTrace();
            }
        }
        %>

     </div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.