amir2 taghvaei
amir2 taghvaei

Reputation: 53

how to call inner class method or variable from outer jsp?

this is my index.jsp page:

<html>

<body>
<%!
public class myclass{
  private final int foo = 42;

  public int getFoo() {
    return foo;
  }
}
%>
</body>
</html>

how to call myclass method or variable in other jsp page ? please help me .

Upvotes: 0

Views: 776

Answers (2)

Ricardo Anjos
Ricardo Anjos

Reputation: 1427

Did you try to use something like

<%@ include file="/myFile.jsp" % >

???

Upvotes: 0

Ryan Stewart
Ryan Stewart

Reputation: 128899

You don't from any "other" JSP. Those declarations should be treated as local to the JSP. If you need a class to be used by multiple JSPs, write it as a separate Java source file, compile it, and include it in your webapp in WEB-INF/classes.

Upvotes: 4

Related Questions