• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Method declaration in a scriptlet??

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic