• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

ArrayList in JSP

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can JSP use ArrayList?

i have this code in my servlet.


then of course i want to get the result and use the request.getAttribute("result") in my JSP page.

but the thing is JSP seems like not knowing ArrayList
i use this code

but it doesn't work. I use Eclipse v3.3 and the JDK 1.5.
The eclipse return "ArrayList cannot be resolved to a type"

Please someone help me.
Appreciate the help. Thanks in advance.
 
Ranch Hand
Posts: 387
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Daniel,

does your servlet have an import statement for ArrayList?
(does your JSP have one too?)

Herman
 
Daniel Gultom
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ow...
i have import statement in my servlet
but not on my jsp. so that is the problem. forget to write these
<%@ page import="java.util.ArrayList" %>

i finally able to use the ArrayList but the problem is i need to
print the String in the ArrayList.

my code is

the thing is request.getAttribute must be an Object.
I try to cast it so that it become ArrayList.
however it returns java.lang.NullPointerException

can anyone solve the problem please.
thanks in advance.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This isn't something that someone on a list of forum can help you with.
This is basic debugging.

If getAttribute is returning null, then you need to examine the code that binds "result" to request scope. Also, remember, that request, as its name suggests, is only good for one request/response cycle. If you bind something to request scope and then try to retrieve it in another request, you will get a null result.
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

did you check (in your servlet) that result = card.view(parameter); is OK?
try to log how many items you have in your ArrayList.

Herman
 
Daniel Gultom
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have solved the problem. thank you for all the assistance
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daniel Gultom:
i have solved the problem. thank you for all the assistance



What was it?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic