1

I have following library class:

public class LibClass{
    public int get(int a, String b) {
        ....
        return 12;
    }
}

How to invoke following method on jsp?

I want to render 12 on jsp.

P.S.

I have restriction that I cannot use scriplets

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

2 Answers2

2

You can do that using expression language. For ex

Assuming that you've a ${instance} in the scope

${instance.get(1,"test")}
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
  • No, Suresh is correct: http://stackoverflow.com/questions/5780504/jstl-or-jsp-2-0-el-for-getter-with-argument – Alan Hay Dec 24 '14 at 14:50
  • it is relevant: **"Passing method arguments in EL is only by EL spec supported in EL 2.2. EL 2.2 is by default shipped in Servlet 3.0 / JSP 2.2"** – gstackoverflow Dec 24 '14 at 19:47
0

There is another way. You can make a simple Bean which gets this value

 public String getDATE(){

 String Date = String.valueOf(new java.util.Date());
  return Date;
 }

and then call the above method with the following jsp tag

<jsp:useBean id="now" class="beans.PropertyBean" />
<jsp:getProperty name="now" property="DATE" />

you can use anything returned from the bean, In above snippet 'PropertyBean' is the name of my custom bean class. Hope this answers your question.

Sharp Edge
  • 4,144
  • 2
  • 27
  • 41