This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP request object. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP request object." Watch "JSP request object." New topic
Author

JSP request object.

Zafar Anwar
Greenhorn

Joined: Jun 06, 2012
Posts: 3

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

Joined: Jan 18, 2012
Posts: 136

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

Joined: Jan 10, 2002
Posts: 60782
    
  65

Please read this JspFaq entry.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Zafar Anwar wrote:
But it prints true. Can you anyone help me?


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

Joined: Jun 06, 2012
Posts: 3
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!
 
Don't get me started about those stupid light bulbs.
 
subject: JSP request object.
 
Similar Threads
Sorting
Doubt about JWeb+ mock exam question
File Operations Program Problem
Sort this!!!!!
help with a statement