File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp init() method

 
vara prasad
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i place any thing in jsp_init() method?
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • 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>
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33716
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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!
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mean jspInit() or jsp_init()?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic