Home > Java > How to execute method with JSP EL tag?

How to execute method with JSP EL tag?

Till JSP 2.1 by using property name on bean <c:out value=”${beanName.property}”/> we used to display the values, internally it will call getter method of that property and value will be printed to browser. But to execute a normal method which doesn’t have getter method or setter method is not possible till JSP 2.1.

if we write <c:out value=”${beanName.methodName}”/> it will throw an error saying : getMethodName is not existing in type beanName.

But from JSP 2.2 on wards we can write <c:out value=”${beanName.methodName}”/> and it will execute the method internally and outputs the results to browser.

This feature is available in Servlet 3.0 environment, Tomcat 7 implementing Servlet 3.0 so we can run this code in Tomcat 7.

Thanks for reading

Advertisements
Categories: Java Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: