views:

18

answers:

1

I know its not recommended, and I should be using tag libraries etc etc.

But I'd still like to know if it is legal to declare methods in a jsp scriplet:

<%
   public String doSomething(String param) {
      //
   }

   String test = doSomething("test");

%>

Is that legal? I am getting some weird compile errors (like a ; is expected) that don't seem to fit. Thanks.

+1  A: 

You need to use declaration syntax (<%! ... %>):

<%! 
   public String doSomething(String param) { 
      // 
   } 
%>
<%
   String test = doSomething("test"); 
%> 
axtavt
I would like to add http://download.oracle.com/javaee/5/tutorial/doc/bnajq.html
org.life.java