This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSP and the fly likes method to return a map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "method to return a map" Watch "method to return a map" New topic
Author

method to return a map

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
I have this simple code in my jsp page and I'm getting an error
"Syntax error on token "(", ; expected"
where the method starts. I can't see what I'm doing wrong. Can someone please look at this?

if(ownerID != null){
HashMap mapOwner = getContact(ownerID);
}
private HashMap getContact(String id){
HashMap mapContact = new HashMap();

return mapContact;
}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Just like with "normal" Java, you can't just declare a method in the middle of another one.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Thanks a lot. I didn't realize the method was inside an if statement.
 
wood burning stoves
 
subject: method to return a map
 
Similar Threads
Comparator as method argument
UrlyBird 1.3.2 locking with no cookie
Would a HashSet be a way to solve this problem?
HQL join syntax
Need Help with pl/sql (Compilation Error)