Hello guys, I don't like cross posting, ... but i tried posting my doubt in sun java forum also, but no replies over there. Members over their just view the topic, they don't reply as such. PLEASE HELP ME! I have few doubts in JSP
1) How to override jspInit() ? I tried one sample program, but the kind of output i get is weird, which leads me to ask this question. I have written one jsp: - simple.jsp
and in index.html i have a hyperlink that points to this jsp: - index.html
Now, the scenario is as follows, 1) The index.html is loaded 2) I click on the "click here" hyperlink 3) The simple.jsp is loaded .... in the console......"My try at overriding the jsp init method !" is printed once. 4) At this moment, i again click on Refresh page button of Firefox, the simple.jsp is loaded again, and in the console it again prints .... "My try at overriding the jsp init method !" ....that means the SOP statement was printed twice!!! 5) i again click on Refresh page button or F5 key several times, ......but from now on the SOP is not printed in the console
Thus, in the console, it only shows, the SOP statement printed twice! .... But, it should print only once, since i have overridden the jspInit() method.....and it is invoked only once......why this strange behavior ?
and my second doubt is :- 2) We have nine implicit objects, are these objects available even in declaration tags <%! ..... %> also ? , ..... because i could neither use the application nor config object, not even request object in the jspInit() method.....i mean, in any normal method declared in declaration tag, the implicit objects are NOT available ... why is it so ?
Thanks and Regards Omkar Patkar
Thanks and Regards
Omkar Patkar (SCJP 1.4)[url]http://javacollectionsnotes.blogspot.com[/url] | [url]http://omkar-myscjpexp.blogspot.com[/url]
The servlet container is free to create and destroy servlets and JSP classes at its discretion. That means you should not rely (or be surprised) on the init and destroy methods to be called more than once.
JSPs aren't exactly the same as servlets. You're right that implicit objects indeed are not available in the jspInit method. If you find yourself doing something that requires them, consider using a servlet instead.
Putting Java code blocks in JSPs is considered bad design anyway.
As to posting on both sites, please read BeForthrightWhenCrossPostingToOtherSites. Posting links to the post in the other site would be the appropriate thing to do. I might also point out that waiting for a mere 12 hours before cross-posting is rather impatient.