• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java method/function in JSP

 
Abraham Jacob
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Is it possible to write a java mehtod/function is a jsp file ?
<%
public void foo(String fooStr1, String fooStr2) {

}
%>
I need to basically run the common piece of code defined in foo with different values of fooStr1 and fooStr2 ?
Thanx,
Abraham
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is possible. You use declarations. See the JSP specification for information on how declarations work.
An example (taken from the spec) is
<%! public void f(int i) { if (i<3) out.println(�...�); } %>
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Abraham Jacob
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!