• Post Reply Bookmark Topic Watch Topic
  • New Topic

passing object from one jsp to another using session

 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to pass an Arraylist object form one jsp(jsp1) to other(jsp2),which gives Null pointer exception.
here's sample code

jsp1.jsp
<form action="jsp2.jsp" method="post">
<%
ArrayList list=new ArrayList();
list.add(.....);--every thig get added successfully.
%>
session.setAttribute("quotesList",list);
</form>

jsp2.jsp
<% ArrayList list=(ArrayList)session.getAttribute("list")%>;
When i print the size of list it gives NULL.
Am i redirecting to jsp2.jsp in correct way.
Also when i use <jsp:forward> it directly takes me to jsp2.jsp.jsp1 dosen't comes.

Please help me out.
 
Vishal Matere
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be session.getAttribute("quotesList")
You should use name name to retrieve attribute as you set it

HTH

V
 
payal Jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,I corrected the line
Arraylist list=(ArrayList)session.getAttribute("quotesList");
Still its giving list size 0.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Inspect this code carefully. Do you see an issue?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!