• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

request.setAttribute ArrayList<Object> woes

 
Gino Giuliani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created an ArrayList<Object> in a jsp to store search results which I want to access from a results page (another jsp), however when I do I get a null pointer exception. My ArrayList is defined as follows:


and on the results jsp I have:

and the error comes here:

Please help me I cannot for the life of me work this one out.
 
Gino Giuliani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry top part should have been

not quite sure how i put in the old version!!!
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First you put the list of arrays into request scope. Then you look for it in session scope.

At least, your first version of the post puts the list into request scope. Your second version doesn't put it into any scope. In neither case will you find it in the session scope.
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, what is that Java code doing in your JSP? If you had been using JSTL and EL, then ${films} would have found the list in request scope without your having to say where it was.
 
Gino Giuliani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep major malfunctions
Thank you
I'm closing this topic anyway as I have figured out most of my problems including the one you just mentioned. phew nothing like 14 hrs of hard reading writing etc. to finally help me get my head around this stuff. its been a long day, if only i'd started sooner....
 
Gino Giuliani
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
coursework so any extra libraries are a no no
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gino Giuliani wrote:coursework so any extra libraries are a no no

Who said anything about extra libraries? The JSTL and EL are part of JSP since 2002.
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gino Giuliani wrote:coursework so any extra libraries are a no no


You're taking a course which tells you to use Java scriptlets in a JSP??? When they have been obsolete for a decade now? And by the way JSTL and EL are standard features of JSP, not "extra". You should be concerned about the way your course is being taught.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic