Heading

Wednesday, March 5, 2014

Web Application in Java with JDBC, Servlets, JSp and MYSQL DataBase-10

 User Home Tabs:

View Registered Products Page:

<%--
    Document   : View_Product
    Created on : Feb 25, 2014, 1:14:13 PM
    Author     : SDSTAFF
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Product Page</title>
                 <link rel="stylesheet" type="text/css" href="First.css">
    </head>
    <body>
        <%
           HttpSession hs=request.getSession(false);
           if(hs==null)
           {
               RequestDispatcher rd=request.getRequestDispatcher("Login_Page.jsp");
               rd.forward(request, response);
               return;
           }
          
          
        %>
         <p id="site">
           G C K Products
        </p>
        <div id="heading">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="Add_Product.jsp">Add Product</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <a href="View_Product.jsp">View Product</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="Logout.jsp"> Logout</a>
        </div>   
                 <p align="right"> Hello <%=session.getAttribute("eid")%></p>
   
        <p id="heading"> Product Details Are</p>
        <table>
            <tr>
                <td>
                    <b> Product ID</b>
                </td>
                <td>
                    <b> Product Name</b>
                </td>
                <td>
                    <b> Product Cost</b>
                </td>
               
            </tr>
            <%!
                String id;
                String name ;
                String cost;
            %>
           
            <%
                Connection con = null;
                Statement st = null;
                ResultSet rs = null;

               

                try{
                    Class.forName("com.mysql.jdbc.Driver");
                    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee","root","password");
                    st=con.createStatement();
                    //st.execute("select  product values('"+a+"','"+f+"','"+g+"')");
                    rs=st.executeQuery("SELECT * FROM  `employee`.`product` LIMIT 0, 10");
                    while(rs.next())
                    {
                        id=rs.getString(1);
                        name=rs.getString(2);
                        cost=rs.getString(3);
                   %>

            
            <tr>
                <td>
                    <b> <%= id %></b>
                </td>
                <td>
                    <b> <%= name %></b>
                </td>
                <td>
                    <b> <%= cost %></b>
                </td>
            </tr>
            <%
               }

            %>
            <%
                 }
                    catch(Exception ex)
                    {
                            out.println(ex);
                    }  
                    finally
                    {
                        con.close();
                    }
              %>
        </table>
                <div id="site1" >
            <p>
                Copy Rights @ G C K Solutions-2014.
            </p>
        </div>
    </body>
</html>

No comments:

Post a Comment