File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "method to return a map" Watch "method to return a map" New topic

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

Joined: Jan 10, 2002
Posts: 61961

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.
subject: method to return a map