• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP request object.

 
Zafar Anwar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In JSP I have.

<%
request.setAttribute("names", new ArrayList().add("ABC"));
out.println(request.getAttribute("names")); // It should print arraylist object. But it prints true. Can you anyone help me?
%>

getAttribute() should return either Object or null.

// But it prints true. Can you anyone help me?
 
Sabarish Venkat
Ranch Hand
Posts: 136
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The array list values are been hold by object so when ever you call the object directly it will show Boolean value alone. what you have to do is keep an iterator and retrieve the values from the array list
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this JspFaq entry.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zafar Anwar wrote:
But it prints true. Can you anyone help me?


because, java.util.ArrayList.add(E) returns boolean
 
Zafar Anwar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:
Zafar Anwar wrote:
But it prints true. Can you anyone help me?


because, java.util.ArrayList.add(E) returns boolean


I got it, thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic