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



Home Answers Viewqa JSP-Servlet how to retrive

Have Programming Question? Ask it here!
 
 
 


Raazan Dongol
how to retrive
0 Answer(s)      2 years and 3 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 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
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
Advertisements
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 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 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
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
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
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
retrive mails from user using java code - Java Beginners
retrive mails from user using java code   how to retrive mails as user "username"??? using java for ex: class Mail{ private String subject... to retrive all mails for user "userName" //and return a set of mail objects
how to insert the physical path of an image in database - JDBC
, the image column is of varchar datatype.. plz can you tell me how to insert image's path.. and also how to retrive that image path and show that picture in a small...how to insert the physical path of an image in database  hello I m
how to pass an array from one jsp to another jsp - JSP-Servlet
how to pass an array from one jsp to another jsp  hi friedns, can any One tell me how to send an array from one jsp to another jsp,pls any one send the code for this.also porvid the code how to retrive the arry in another jsp
how to make combinations - Development process
how to make combinations  import java.util.*; interface Expression... ActionExpression implements Expression { retrive the action from here; } class ConditionExpression implements Expression { retrive conditions
how to use views - Java Beginners
how to use views  how do i retrive data from a database and display it gui  Hi Friend, We have retrieved the value from the database and show it in Swing table. import javax.swing.*; import javax.swing.table.
how it maps to Struts
how it maps to Struts  What is MVC and how it maps to Struts
how to conduct the test in java
how to conduct the test in java  how to conduct the test in java
how make ID - Ajax
how make ID  how make a ID in eyeball chat
how formBackingObject() method will work.
how formBackingObject() method will work.  How the formBackingObject method will behave
How To Turn On the Session Support?
How To Turn On the Session Support?  How To Turn On the Session Support
How to use Arraylist object in <s:dobleselect> .... struts 2? - Struts
How to use Arraylist object in .... struts 2?  Hi Members, I saw the example of tag in roseindia, its very useful. But I have to use my ArrayList... select box is passed as an argument to retrive the list for second select box
how to download file
how to download file  How do I let people download a file from my page
how to create a queue - JMS
how to create a queue  Can u please tell me how to create q queue in JMS and also tell me how to write a program to Send a Static Message for JMS Queue ....please i need it urgently
How to? - IDE Questions
How to?  I have download this Barbecue 1.5 beta 1 (barcode generator). How should I properly put it in Netbean 6.5? It's also said that I can adjust the barcode width, heigth & resolution through http://host:port/barbecue/. How
how to install jboss - EJB
how to install jboss  when i installed jboss at startup jboss generating errors . unable to run ejb3
how to ajax components are synchronized
how to ajax components are synchronized  How to ajax components are synchronized   Hi, Ajax consist of set of technologies to get the data from server Asynchronously. It is the object of var xmlHttp; which
how to printing - Java Beginners
how to printing  how to print some thing on output without using system.out.print()and without using print writer class ?  Hi Friend, Try this: import java.io.*; public class Print{ public static void main
how to use - EJB
how to use  I am buiding a Shopping cart and i want to fetch image and its product id from the database(MySql) and fetching of image should be done by JPA
How TCP/IP works ?
How TCP/IP works ?  hello,, Can some body tell me how TCP/IP works?   hii, TCP/IP is just a protocol that allows different nodes on the network/Internet to share resources and without TRANSMISSION CONTROL PROTOCOL
how to code - MobileApplications
how to code  I am developing a wap site. i want that when any user hit my site then it shows the mobile manufacturer and modal at main page. please tell me how to do this code to indentify the mobile manufacturer and modal at my
how to print - Java Beginners
how to print  how to print something on console without using System.out.print() method ?  Hi Friend, You can use PrintWriter to write anything on the console. import java.io.*; public class Print{ public static
how to run - Java Beginners
how to run   how to run java program... brifely  Hi Friend, Java Virtual Machine is responsible for running java program.Java uses the "javac" command to compile the program and after compiling,uses "java" command
how to do this - JavaMail
how to do this  i have created three HTMl documents. i want to display three HTML documents combinely with in a single frame. can i save 3 HTMl combinely as single JSP.If combine how ? Plese send examples not only with HTML's
How to destory session in PHP
How to destory session in PHP  Hi, I have to write a php page for logout. Please tell me what i should write? Thanks   Hi, You can use following code for logout: <? session_start(); session_destroy(); header
how to integrate EJB with Struts
how to integrate EJB with Struts   I am new to EJB. Up to now I wrote applications by using JDBC and struts.Now I want to use EJB with struts for this what should I do?   Hi Friend, Please visit the following link
How to sort the rows in SQL?
How to sort the rows in SQL?  How to sort the rows in SQL?   Hi, Here is the answer, The ORDER BY clause allows you to sort the records in your result set. The ORDER BY clause can only be used in SELECT statements
how to run applet - Applet
how to run applet   Hi everybody i am using connecting jdbc in applet program. this is executed successfully with appletviewer command >... how can i execute in browser ? Thanks in advance thanks for seeing my
how to update the text file?
how to update the text file?  if my text file contains a string and integer in each line say,: aaa 200 bbb 500 ccc 400 i need a java code to update the integer value if my input String matches with the string in file. please
how to establiish an smtp server ?
how to establiish an smtp server ?  we have an need of establishing an smtp server . "our scenario is that first when the customer enters his details into our resistration form and clicks the submit button , then depending
how to write in xml? - XML
how to write in xml?  can anybody give the code how to write in xml file. i wan to write inside the tag, so what i have to do? Thanks...  Hi friend, Code to help in solving the problem : import java.io.*; import
How to run? - Hibernate
How to run?  Hiiiiiiiiiiiii friend.. i am Magesh, doing MCA at Madurai in Tamilnadu. i know little bit about Jsp,Servlet.. But my friends are told hibernate is a new entry to Java. so plz try to tell how to use
how to set image - EJB
how to set image   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response... in this pdf, how can i set pls help me sir, my image in E:/rose.jpg,how can
How to Work - JSP-Servlet
How to Work  Respected sir i am ramesh doing final year MCA.Now i am doing final year project using java,jsp,servlet.i only know java.i want details about where we save the jsp and servlet file and how we link with java.send one
how to update the text file?
how to update the text file?  my textfile with name list.txt: Rice 25.0 500 Wheat 80.0 150 Jowar 50.0 150 .... ....20 lines. java code: import java.io.*; import java.util.*; class
How to sort json object?
How to sort json object?  I've been looking for a while and want a way to sort a JSON object like this: {"results": [ { "layerId": 5, "layerName": "Pharmaceutical Entities", "attributes": { "OBJECTID": "35
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values... and then retrive data to perform operation in execute() method in Struts Action
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values... and then retrive data to perform operation in execute() method in Struts Action
how to use dirivers - JDBC
how to use dirivers  i try connecting to a database with this code but i get this ClassNotFoundException, already i have added the path to the connector to my classpath variable. here is the code; import java.sql.Connection
how to debug parameters in the hibernate query
how to debug parameters in the hibernate query  how to debug parameters in the hibernate query
How can we destroy the cookie?
How can we destroy the cookie?   How can we destroy the cookie
Advertisements
 

 

 

DMCA.com