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 7038355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:39:33+00:00 2026-05-28T01:39:33+00:00

i have bean that contain method [void return] and want access to this bean

  • 0

i have bean that contain method [void return] and want access to this bean in JSP.

public class A {

  public void run() {}
}

add below code to spring config file.

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="exposeContextBeansAsAttributes" value="true"/>
</bean>
     <bean id="a" class="com.example.A"
 >
</bean>

now in my JSP page :

${a.run}

but this solution not work.please help me for access spring bean on JSP page.

  • 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-28T01:39:34+00:00Added an answer on May 28, 2026 at 1:39 am

    Inject the bean into your controller and expose it as part of the model.

    But why do you need to call run from the JSP?

    JSP EL expects to follow JavaBean naming conventions; this example won’t work the way you expect. The easiest option is to rename the method, or provide an additional method, that follows the JavaBean naming convention and calls run.

    Edit to reply to comment.

    If you need to call a method from a link, you have two (reasonable) options: link to a controller action that calls the injected service, or make an Ajax call to a controller method that calls the injected service.

    There’s still zero reason to be making the service call directly from the view layer (the JSP).

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

Sidebar

Related Questions

We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager
Assuming that I have a CronTriggerBean similar to <bean id=midMonthCronTrigger class=org.springframework.scheduling.quartz.CronTriggerBean> <property name=jobDetail ref=reminderJobDetail
Imagine that i have the following code: <a:repeat value=#{bean.getList()} var=x > <li class=la> <span>
I have a base class with a virtual method, and multiple subclasses that override
I have a requirement to sort some strings that contain data like this: var
I have this Person class that is part of various other transactions like a
I have a MDB (Message driven bean) that receives messages with String which represent
We have some JavaEE5 stateless EJB bean that passes the injected EntityManager to its
I would have thought that this would be an easy thing to do, but
I have a Controller bean (SearchController) that has two managed bean as managed properties

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.