Scriptlets can contain any code fragments that are valid for the scripting language specified in the language directive. Whether the code fragment is legal depends on the details of the scripting language (see Chapter JSP.6).
When all scriptlet fragments in a given translation unit are combined in order they appear in the JSP page, they must yield a valid statement, or sequence of statements in the specified scripting language.
So... its sorta tricky how they word it -- a scriptlet can contain a method if its legal in the scripting language for it to containa method. As of right now Java is the only scripting language.... and as of right now -- its not legal.
That's because all of your scriplets are converted at request time into fragments of the _jspService(request,response) method. And in Java it's illegal to have a method defined within another method -- but it IS legal to define an anonymous class or local class.
Also, you can define a method in a <%! declaration statment%> that way it will be put outside the _jspService method.
depending on why u need to use a method in the jsp page, there are many ways of going about.
U can even write a custom tag and put ur method in it.
U should check this link out....
just thought i'd give u another pointer...
hope this helps..it even has an example