It's not a secret anymore!*
The moose likes JSP and the fly likes jsp init() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp init() method" Watch "jsp init() method" New topic
Author

jsp init() method

vara prasad
Ranch Hand

Joined: Dec 21, 2004
Posts: 47
can i place any thing in jsp_init() method?
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
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>


James Carman, President<br />Carman Consulting, Inc.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
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

Joined: Oct 12, 2000
Posts: 5093
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.


42
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Did you mean jspInit() or jsp_init()?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp init() method
 
Similar Threads
NX: When should I throw DuplicateKeyException?
Changin font in a JTextArea
Finalization Method
Sharpen your Pencil - Page 323 in HFEJB
garbage collection