| Author |
Accessing implicit objects in declarations?
|
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
The implicit objects are defined locally inside _jspService(...) method and they are NOT accessible in declarations. Is it considered a good practice to access them outside the _jspService method (by one means or another)? Looking for some guidance on this. Pros/Cons Thanks. - satya
|
Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
|
 |
Chintan Rajyaguru
Ranch Hand
Joined: Aug 19, 2001
Posts: 341
|
|
If the implicit variables are defined inside _jspService method, there is no way you to access them unless you define a variable in higher scope and assign implicit variable to it. Based on what I know, the only logical place to access implicit variables is in doXXX methods of custom tags. A bad programming practice could access them outside the _jspService methods but then you loose the basic characteristics (such as thread safety). I eould love to see more comments... Chintan
|
ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
loose the basic characteristics (such as thread safety). implicit objs are never gaurenteed to be thread safe. Some of them are, because of their nature, but there's nothing basic abt that... - satya
|
 |
Ram Dhan Yadav K
Ranch Hand
Joined: Aug 13, 2001
Posts: 321
|
|
I agree with Chintan. Is it considered a good practice to access them outside the _jspService method (by one means or another)? What do you mean by outside _jspService, is it outside the scope of the _jspService or in a user defined method which is with in the scope of _jspService i.e private methods which you access only with in jspService method. Then it should be legitimate and should workfine. But if you try to access them outside the scope of _jspService, you will end up sending one customers bill to another customer Would like to hear more comments.
|
Ram Dhan Yadav (SCJP, SCWCD, SCJA-I, IBM EC(483))
"We are what we repeatedly do. Excellence, then, is not an act, but a habit."
|
 |
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
|
|
What do you mean by outside _jspService, is it outside the scope of the _jspService That I agree to. or in a user defined method which is with in the scope of _jspService i.e private methods which you access only with in jspService method. Then it should be legitimate and should workfine. Say I define a private method using a declaration private void myJunkJSPMethod(JSPWriter out) { // implementation } and call this from inside the _jspService(...) method passing it the implicit out obj. Is that good/bad? I agree with Chintan, thats bad, theoritically. But just curious if there's a situation when anyone did this? Maybe I am splitting hairs.... :roll: Thanks. - satya
|
 |
Ram Dhan Yadav K
Ranch Hand
Joined: Aug 13, 2001
Posts: 321
|
|
|
I am not sure about JSP, but i did the same stuff with servlets and it workd fine. There is not prblem even with load tests and the code does not break on production. I guess it working fine as of now!
|
 |
 |
|
|
subject: Accessing implicit objects in declarations?
|
|
|