• 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

jsp init() method

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i place any thing in jsp_init() method?
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. You're limited to valid Java code. ;-) But seriously, it's just another method like any other, so theoretically you could put any logic in there that you want, right?

<soapbox>
I personally don't like to use ANY scriptlet code in my JSPs, but I guess that's just personal taste. If you're just prototyping, by all means do so, but if you're trying to develop JSPs that will be used by others, it's better to go with a tag library (such as JSTL) which makes the page more readable.
</soapbox>
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vara,
In addition to what James said, initialization code should go in a servlet. The servlet can foward to the JSP when you are done. I can't think of any good uses for the jsp_init() method.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
Vara,
In addition to what James said, initialization code should go in a servlet. The servlet can foward to the JSP when you are done. I can't think of any good uses for the jsp_init() method.



Well put!
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
besides which it may well be called something else when deploying to another appserver...

As stated, avoid the use of scriptlets and NEVER write methods in JSPs even if you do use them.
With a bit of thinking any scriptlet code can be avoided.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you mean jspInit() or jsp_init()?
 
reply
    Bookmark Topic Watch Topic
  • New Topic