Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 972595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:08:57+00:00 2026-05-16T03:08:57+00:00

How can an object be accessed from the ModelMap in jsp so that a

  • 0

How can an object be accessed from the ModelMap in jsp so that a method can be called on it? Currently I recieve this error:

Syntax error on token "$", delete this token

JSP

<body>
        <% MenuWriter m = ${data.menus} %>
        <%= m.getMenus()%>  
</body>

Java

@Controller
@RequestMapping("/dashboard.htm")
@SessionAttributes("data")
public class DashBoardController {

    @RequestMapping(method = RequestMethod.GET)
    public String getPage(ModelMap model) {
        String[] menus = { "user", "auth", "menu items", };
        String[] files = { "menu", "item", "files", };
        MenuWriter m = new MenuWriter(menus, files);
        model.addAttribute("menus", m);

        String[] atocs = { "array", "of", "String" };
        model.addAttribute("user_atocs", atocs);

        return "dashboard"; 
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:08:58+00:00Added an answer on May 16, 2026 at 3:08 am

    The <% %> syntax is deprecated, and shouldn’t be used any more.

    The equivalent in modern JSP of your JSP fragment would be:

    <body>
       ${menus.menus}
    </body>
    

    Obviously, that looks confusing, so you may want to consider renaming parts of your model for clarity.

    Also, your annotation

    @SessionAttributes("data")
    

    does nothing here, since you have no entry in the ModelMap with the key data. This is only useful if you want to keep the model data across the session, which it doesn’t seem you need to here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have multiple resources in a project that can only be accessed from
I'll have a database object that can be accessed from multiple threads as well
I am wondering if the NSUserDefaults object is shared and can be accessed from
In the following code, can the x member be accessed from the nested object
The problem is that all Object attributes apart from 'name' call the error 'id/url/whatever
JCIP defines Guarded objects as: Guarded . A guarded object can be accessed only
Let us say my domain object can contain a bunch of objects like this:
What is maximum size of data that an object can hold on the iPhone?
I have drawn an object on NSView subclass. How can the object know that
I have a MySerialPort class/object accessed from FormGUI. After creating a MySerialPort object, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.