williamsandonz
williamsandonz

Reputation: 16450

JSP calling function from front-end

Hi there I've successfully setup a function in JSP can calling it from the same file. I want to separate my logic from presentation, how would I go about throwing this function <%! somewhere else in a class and then accessing it from my .jsp front-end file>?

Upvotes: 1

Views: 168

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94653

Yes, you must have to avoid Java code in JSP files. Take a look at - How to avoid Java Code in JSP-Files? You need to place (create and compile) a public class definition under the WEB-INF/classes. For instance,

package test;

public class Foo
{
  public void methodOne() { .. }
  public static void methodTwo() { .. }
}

Upvotes: 2

Related Questions