• 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

Can I write a method in a jsp page

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I know that jspInit() and jspDestroy() methods can be written in a jsp file. My question is can I write some more methods in the same jsp file and if I can write those methods then how can I call them?

Thanks
Mahesh..
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
declaration is used like a scriptlet to embed code in a JSP, but code embedded by
a declaration appears outside of the _jspService() method. For this reason code
embedded in a declaration can be used to declare new methods and global class
variables, but caution should be taken because code in a declaration is not
thread-safe, unless made so by the writer of that code.
[ December 06, 2004: Message edited by: Babar Qadri ]
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can call that method or use that instance variable in your jsp page using scriplets. now the call would be inside your _jspService() method. But again that method or variable would not be thread-safe, as Babar mentioned in his post.

example,

 
Mahesh Malviya
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks babar and adeeel. I got my answer. Thank you very much.

bye
Mahesh Malviya
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic