Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Accessing implicit objects in declarations?

 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 321
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic