Share on Google+Share on Google+

2 Answer(s)      6 years and 10 months ago
Posted in : JSP-Interview Questions
i used arraylist in servlet as shown

ArrayList <Integer> total = new ArrayList <Integer>();


when I code this like in my jsp
<%ArrayList<Integer> data= new ArrayList<Integer>(); %>

<%Iterator itr;%>
<% //List data;
data= (ArrayList)session.getAttribute("efg");
for (itr=data.iterator(); itr.hasNext(); )


Its not printing the values. do i need to do any typecast or anything else. I'm sure mu k[i] have some value. please let me know.



View Answers

June 11, 2010 at 12:39 PM

Hi Friend,

We have send you the code which was working. Check whether the values of CARTUPDATE.jsp displayed on servlet or not. It seems that values are not getting from jsp to servlet.


November 24, 2011 at 4:05 AM

sorry someone could tell me or help send from this code as a catalog for me to print the session through the whole article and was printed as an ArrayList.

<! - The import ->
<% @ Page language = "java"%>
<% @ Page import = "java.sql.Connection"%>
<% @ Page import = "java.sql.DriverManager"%>
<% @ Page import = "java.sql.ResultSet"%>
<% @ Page import = "java.sql.Statement"%>
<center> <h1> Catalog </ center> </ h1>
if (request.getParameter ("submit")! = null)
String name = request.getParameter ("user");
session.setAttribute ("name", name);
out.println (name);
out.println ("lacking send button.");
   / / Connecting to bd
   Class.forName ("");
   Connection connection = DriverManager.getConnection ("jdbc: mysql: / / localhost/proyecto1", "project1", "123");

   if (! conexion.isClosed ())
      / / The query
      Statement st = conexion.createStatement ();
      ResultSet rs = st.executeQuery ("select * from product");
     / / Put the results in a html table
      out.println ("<table
      while ( ())
         out.println ("<tr>");
         out.println ("<td>" + rs.getObject ("id_producto ")+"</ td>");
out.println ("<td>" + rs.getObject ("nombre_prod ")+"</ td>");
out.println ("<td>" + rs.getObject ("price ")+"</ td>");
out.println ("<td> <img src=http:\\\\localhost:8080\\proyecto\\imegen\\"+rs.getObject("imagen")+"> </ td>");
out.println ("<td>" + rs.getObject ("description ")+"</ td>");
         out.println ("</ tr>");
      out.println ("</ table>");
      / / Close the connection
      connection.close ();
      / / Connection failed
      out.println ("failure");
catch (Exception e)
   / / Error at some point.
   out.println ("Exception" + e);
   e.printStackTrace ();
</ Body>
</ Html>
<p> <a href="agenda.jsp"> list of users </ a> </ p>
<p> <a href="ogin.jsp"> Home </ a> </ p>
<p> <a href="insertar.jsp"> register </ a> </ p>

Related Tutorials/Questions & Answers:
arraylist   Using arraylist class , what type of exception are throws, how can write a java programe   An ArrayList can throw... ArraylistException { void buildAlphabet() { ArrayList list = new ArrayList
ArrayList  import java.util.*; class ArrayListDemo2 { public static void main(String args[]) { ArrayList al=new ArrayList(); al.add("one"); al.add("two"); al.add("three"); al.add("four"); for(int i=0;i Expected
arraylist  Hi How can we eliminet duplicate element from arraylist? How can we find highest salary from arraylist ? How can we highest key value pair from map? Thanks Kalins Naik   Remove duplicates from Arraylist
arraylist  Hi how can we eliminet duplicate element from arraylist in java? how can we achieve data abstrcation and encapulation in java? how many type of modifier are there in java? Thanks kalins anik   Remove
arraylist  Hi i have class A , i have added employee name and id in arraylist, then how can i find out all infomation of class A using emplyee... data into an arraylist and display the data of the particular employee according
% *(noOfYearService/2). Store each employee information in different arrayList depending on his
arraylist of an arraylist
arraylist of an arraylist  Can anyone suggest me how to use arraylist of an arraylist?? how to put data into it and get data from it???? becoz i want to make rows and column dynamic which can grow as per requirement?????/ plz
Java ArrayList
Java ArrayList   How to declare unique ArrayList
arraylist and vector
arraylist and vector  what is the diff b/w arraylist and vector
ArrayList and Vector
ArrayList and Vector  hello, Why ArrayList is faster than Vector?   hii, ArrayList is faster than Vector, because ArrayList is not synchronized. Synchronization will reduce the performance of Vector
arraylist in java
arraylist in java  arraylist in java   Array List Example in java
ArrayList object
ArrayList object  i have am ArrayList object it containg data base records in it, now i want to display this ArrayList object data in my jsp programe, plz help me
ArrayList elements
ArrayList elements  how to print ArrayList elements in reverse order... ArrayListReverse { public static void main(String[] args) { ArrayList list=new ArrayList(); list.add("Innova"); list.add("Alto
Java arraylist of arraylist
Java arrayList can make the use of other arrayList.  In one arrayList other arrayList can be added as the object  It works as two dimension array. Example of Java Arraylist of Arraylist import
comparing arraylist of an multi dimensional arraylist
comparing arraylist of an multi dimensional arraylist  can anyone help me in solving the following issue: actually i have an arraylist called dany... have to compare each arraylist with each other. like i have to take 1st arraylist
accessor arrayList
accessor arrayList  how to use an acccessor to return an arraylist?   public List getProductList(String itemName) { List list=new ArrayList(); //Add your item in the list return list; } You may wish to browse
ArrayList in java
ArrayList in java  sir i have a class contains id,name,marks of students and a parameteraised i created an arraylist... to access marks from arraylist
ArrayList programe
ArrayList programe  How to write a java program to accept an array list of Employee objects. search,delete and modify a particular Employee based on Id Number (like ID,Name&Address
Cannot assign an ArrayList to an empty ArrayList
Cannot assign an ArrayList to an empty ArrayList  I have a java file, in which a method returns an ArrayList. This ArrayList is supposed to contain... StudentsManager's methods statically. studByYear(year); returns an ArrayList of all
vector and arraylist
vector and arraylist    suppose i have class A { public static arrylist a1(){} class B{ public static vector b1() {} } my question is how to class B method in Class A and how to get vector object values in class A without
java arraylist
need to create arraylist whose name is same as type value(e.g : list1,list2... which is having type list1 in the arraylist named list1. the problem here... help how to handle this through java arraylist. xml : <?xml version='1.0
arraylist problems?
arraylist problems?   myprogram needs to ask the user for a file name. The file will contain a name on each line. Put each of the names into an ArrayList. After you have put all of the names into the ArrayList search through
Java arraylist, linkedlist
Java arraylist, linkedlist  What is the major difference between LinkedList and ArrayList
Remove multiple elements in arraylist
Remove multiple elements in arraylist   how can we remove multiple values in arrayList? only remove method we used for single remove.but i want to delete multiple value in arrayList
ArrayList as an argument to another class
ArrayList as an argument to another class  how do you pass arraylists as arguments to another class, and how does the method/class accept this arraylist for use
Java ArrayList Example
Java ArrayList Example  How can we use array list in java program..."); array.add("Arun"); System.out.println("ArrayList Size...++){ System.out.println("ArrayList Element"+i+" :"+array.get(i
Printing ArrayList - JSP-Servlet
Printing ArrayList   I have a code in servlet like this ArrayList total = new ArrayList (); session.setAttribute("efg",total...(request,response); to print the values in ArrayList total, I did this in my JSP
Can ArrayList accept an ImageIcon >>????
Can ArrayList accept an ImageIcon >>????  haw can create ArrayList witch can accept Image ..mean when i use add() method, instead item let me add image to the ArrayList in run time .{should be the program using GUI
Java Spring Hibernate Struts Training why do not required application restart after jsp changes? How to use contentType Attribute in JSP? How to connect to MySQL in JSP? JSP Comment Types with example How to use ajax in jsp? How to access the database from JSP? how to show image as a link which path coming from database jsp netbeans javascript Logos on mail inbox. I want to update the multiple values of database depending on checkbox..? Please help me out.. jsp 18/04/2013 JSTL how to access element added via javascript dynamically using jsp code Electronic spreadsheets are useful in situation An E-mail protocol for storage JSP JSP JSP jsp servlets Exception: com.mysql.jdbc.Driver display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist Jsp Query run command prompt from jsp program question for c++ please help me how to set up Netbeans for JSP 3 dropdown list from the database using JSP autocompletion in textfield fetching from database in jsp openning the pdf or doc file in same jsp EXT JS tt need coding JSp session time out how to display values from database into table using jsp how to set the class path variable in tomcat ? need help please online examination system mini project problem in writing coding. Please help me. How to read the body content of custom tag? need help...................please please help me jsp coding please. help me image upload Assertions I want to store the value of local variable into Global variable how to create customise shortcut keys in jsp?


Advertisement null