This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Small Doubt

 
Rajan Chinna
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why there are some methods and variables which start with _ (underscore) character in JSP servlet java file? Is there any special purpose behind that?
 
K Anshul
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it refers to methods and variables which are generated by the server and which u shouldn't override in ur code.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Different application server will generate different set of the code, even with the same JSP, and thus, I guess this is just their own preference.

As if you follow the coding practice stricty, you wont write your code variables started with "_".

Nick
 
Mary Wallace
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But most of the application sever generate class files starting with "-".
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The coding practice is to assure the readability and the standard, however, there should be no/less people who will read the generated codes, just like we seldom read EJB Stubs.

Thus, this is not a big deal indeed.

Nick
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajan Chinna:
Why there are some methods and variables which start with _ (underscore) character in JSP servlet java file? Is there any special purpose behind that?


The only member of a JSP servlet class that must use the underscore is the _jspService method, which is part of the JSP API standard. All other uses of underscore are the parlance of the container's JSP engine (as others have mentioned already).

-Bryan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic