how to retrive
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"> </td></tr>
<tr><td colspan="9" align="center">No Record Avaliable</td></tr>
<%
}
%>
it's not working..ple anybody can correct is code.....
View Answers
Ads
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
Advertisements
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
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
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 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
Request URl using Retrive data from dtabase
Request URl using
Retrive data from dtabase Using With GWT
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
java [ cannot retrive date from sql ] why??
java [ cannot
retrive date from sql ] why??
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.ParseException... cannot I
retrive data from bd even if I put correct data in it
if( rs.next
correct the sql error and retrive data....plez
correct the sql error and
retrive data....plez i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch in criteria expression" plez do help me and studentId's datatye is number
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp? Hi,
I need help in jsp to display values of an ArrayList in jsp.
There is a java file containing a method which is returning an
ArrayList.
I want to display the records
retrive data from database using jsp in struts?
retrive data from database using jsp in struts? *search.jsp*
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
Retrive values from an arraylist and display in a jsp?
Retrive values from an arraylist and display in a jsp? Hi,
I need help in jsp to display values of an ArrayList in jsp.
There is a java file containing a method which is returning an
ArrayList.
I want to display the records