Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet how to retrive
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Raazan Dongol
how to retrive
0 Answer(s)      2 years and 4 months ago
Posted in : JSP-Servlet


this my servlet page.. @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response);

     DataSource ds=null;
     Connection con = null;
     PreparedStatement smp = null;
     ResultSet rs = null;
     try {
    Context c =new InitialContext();
         ds = (DataSource)c.lookup("jdbc/surevac");
           con =ds.getConnection();

           ArrayList al=null;
       ArrayList Product_List =new ArrayList();
           String query = "select * from  PRODUCT_LIST";
           smp = con.prepareStatement(query);
              rs = smp.executeQuery(query);
         while(rs.next())
            {
                al  = new ArrayList();

              al.add(rs.getInt(1));
              al.add(rs.getString(2));

             System.out.println("al :: "+al);
              Product_List.add(al);
            }
         request.setAttribute("Product_List",Product_List);

            String nextJSP = "Administrotar/Product_list.jsp";
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
            dispatcher.forward(request,response);
            con.close();


    } catch (Exception e) {
        System.out.println("......."+e);
    }
}

and this is my jsp page.. <% String bgcolor=""; int count=0; List viewList = new ArrayList(); Iterator viewItr;

if(request.getAttribute("userList")!=null && request.getAttribute("userList")!="")
{
    List userList =  (ArrayList)request.getAttribute("userList");
    Iterator itr = userList.iterator();

    while(itr.hasNext())
    {

        if(count%2==0)
        {
         bgcolor = "#C8E2D1";
        }
        else
        {

            bgcolor = "#EAF8EF";
        }

        viewList = (ArrayList)itr.next();
        int id = Integer.parseInt(viewList.get(0).toString());
        viewItr = viewList.iterator();
        %>
        <tr style="background-color:<%=bgcolor%>;">

        <%  
        while(viewItr.hasNext())
        {

            %>
            <td><%=viewItr.next()%></td>

            <%

        }
        count++;
        %>
        <td><input type="button" name="edit" value="Edit" style="background-color:#49743D;
                               font-weight:bold;color:#ffffff;" 
                               onclick="editRecord(<%=id%>);" >
                    </td>
            <td>
                                <input type="button" name="delete" 
                                       style="background-color:#ff0000;
                                       font-weight:bold;;color:#ffffff;" 
                                       value="Delete" 
                                       onclick="deleteRecord(<%=id%>);"></td>
        </tr>
        <%
    }
}
if(count==0)
{
    %>
    <tr><td colspan="9" align="center">&nbsp;</td></tr>
        <tr><td colspan="9" align="center">No Record Avaliable</td></tr>
    <%
}
%>

it's not working..ple anybody can correct is code.....


Advertisement
View Answers

Related Tutorials/Questions & Answers:
how to retrive
how to retrive  this my servlet page.. @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response
how to retrive data grom database in jsp pages.
how to retrive data grom database in jsp pages.  sir, i have problem to retrieve data from table of the database on the html web pages , so would yuo please help me about this. please post me solution on my email id
Advertisements
how to retrive other details with an image - Swing AWT
how to retrive other details with an image  hello I m trying to retrive an image as well as some other values from database.. but only image..... followingis my code..plz advice me how to get both values as well as image at a same
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser
how retrive data from google analystics dashbord on the client machine
how retrive data from google analystics dashbord on the client machine   sir i am digvijay subj: retrive data from google analystics dashbord respected sir, According above subject i request you , i want retrive data from
How to retrive a particular record from database in php with mysql?
How to retrive a particular record from database in php with mysql?  ... names are username,password,email,firstname,lastname. But i want to retrive 3 rd record based on username and password. I dont know how to retrive in php with mysql
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
how can retrive value from combo box in servlet?
how can retrive value from combo box in servlet?  i have a jsp page with combobox. And i want to get value from combox to servlet
How to retrive an inmage from database and displaying it in imgae box - Swing AWT
How to retrive an inmage from database and displaying it in imgae box ...? I want to retrive an image from database and to display it in a small imagebox or pane in a JFrame.. is this possible? can you plz help tell me how we can do
how to retrive the particular data from database in php with mysql?
how to retrive the particular data from database in php with mysql?  when am using mysqlfetcharray() that display the following error. the code look like this.. <?php $con = mysql_connect("localhost","root
retrive values - JSP-Servlet
retrive values  how to get multiple values from html to jsp
Retrive Values
Retrive Values  I want to retrive the values between the td by the id using the javascript.So please help me... html form like this <TABLE...; </TABLE> And I want to retrive Cell 1,Cell 2,Cell 3
how to convert image into bytes and also retrive the image from that bytes - Java Beginners
how to convert image into bytes and also retrive the image from that bytes  how to convert image into bytes and also retrive the image from that bytes?  Hi friend, Code to help in solving the problem : import
retrive values - JSP-Servlet
retrive values  how to retrive multiple values from html to jsp  Hi Friend, Try the following code: 1)calljsp.html: Enter Name: Enter Address: Gender:MF Qualification: Btech MBA MCA MSC
retrive mails - Java Beginners
retrive mails   hi how to retrive mails using mysql in java not using pop3 or imap directly from database i am using dbfile system in james server.header should be store in database and message in file system thanks bala
image retrive into DataBase - JDBC
image retrive into DataBase  Dear Deepak Sir, How to retrive the image into DataBase. Thanks & Regards, VijayaBabu.M  Hi... shows you how to retrieve image from database using a servlet and then show
File Upload and Retrive files
File Upload and Retrive files  Can any body help me am getting an error in uploading file. into mysql database.... thank's in advance
retrive data from database?
retrive data from database?  hellow i have a database sheet name..... now i want retrive sn,roll no and name and textbox like....,rllno,and name retrive
store and retrive image from the database
store and retrive image from the database  please provide me with the code and the explanation of what each line does for the below query. -how to store and retreive images from sql database using sql commands -how to store
retrive data from database
retrive data from database   hi.. i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in database access sheet i want to view it at any another
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
To retrive data from database - Struts
To retrive data from database  How to get values ,when i select a select box in jsp and has to get values in textbox automatically from database? eg:I have three tables in database,and in jsp page if i select courseid in select
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
jsp retrive image - JSP-Interview Questions
jsp retrive image  How to Display Images in JSP retrieved from MYSQL database? plz help me..  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Thanks
after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp
the submit button,how can v store the data in db, n hw can v retrive the data frm...after entering details in reg page,n enter the submit button,how can v store the data in db, n hw can v retrive the data frm db in jsp  i ve creted
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help me out..... in file create project i am entering proj details such as id name...; } } in SearchProjDAO i have to call servlet also how can i do this i have
GWT -- retrive the data from Database
GWT -- retrive the data from Database  the user can create an event. In the create page, we have three buttons. Save as draft, preview and save and post buttons. Once the user entered all the datas and if he clicks the Preview
insert and retrive data and time - SQL
insert and retrive data and time  hello everybody . Is there any method in java so that we can insert current system time and then it can be retrieve that date and time from database ? ..........................  
store and retrive image from database - JDBC
store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image in database using Java. import java.sql.*; import java.io.*; public class
to retrive e mails as per user name - Java Beginners
to retrive e mails as per user name  hi friends, how to retrive e mails as per user "user name " for ex: class Mail{ private String subject... to retrive all mails for user "userName" //and return a set of mail objects
 

 

 

DMCA.com