Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Method declaration in a scriptlet??

 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pals,

Can we define a method in a scriptlet??
If yes,that method goes inside the _jsp_Service method...then is that valid??
Could someone explain me....

Thanks in advance,
Javainn
 
Wei-ju Wu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could define a method using a jsp declaration

<%!
MyReturnType myMethod(MyParam1 param1, ...) {

... some code
}
%>

but even though this is scripting, this is not exactly a scriptlet but a jsp declaration. The method will be placed within the compiled jsp class, outside of your _jsp_service() method.

If you would put a method inside a scriptlet, it would be placed inside the _jsp_service() method upon jsp translation, so the Java compiler would complain about placing a method inside a method.
 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks once again Wei-ju Wu ,

Even i thought of the same thing that the method cannot be placed inside a method...But wanted to make sure...as I am new to this technology...Thankyou so much for your valuable answers.

javainn
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic