• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP with javascript, session info not getting populated  RSS feed

 
Pratheek Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I set a session attribute in my jsp, which is writing out to the logs perfectly, and the data is right. however, after setting the session attribute, ... code bit looks like this

while (rsSCOComments.next()) {
comments = rsSCOComments.getString("Comment");
session.setAttribute("SCOCOMMENT", comments);
System.out.println("sco comment is: " + session.getAttribute("SCOCOMMENT"));
%>
<script>showComments()</script>
<%
}
i'm calling a showComments() javascript method which opens a popup window and pre-populates the content ....

and the bit of the method...
tmp.write('<td div id="SUBLEFT"><p><%=session.getAttribute("SCOCOMMENT")%></p>'); returns null.

the showComments() method is defined at the top of the page..

what am i doing wrong?
Can anyone please assist?

Many thanks.
Sharma
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do realize that, by putting the setAttribute call inside your loop, you're overwriting all previous entries with the current one on each iteration, right?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!