Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

declaration contents appears in jspservice method  RSS feed

 
tue march
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ppl,

we know that scriptlets and expressions go inside a _jspservice(), and declarations go outside of _jspservice() when a jsp is converted a servlet.

But in one sample programs which i typed and executed, it is showing all the three scriptlets, expressions and declarations all going inside _jspservice().

so can anybody explain which is true either declaration goes inside or not.

i am totally confused.

THanks,
good guy
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show your jsp code.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Declarations made outside of the service method are instance variables.
<%! String notTreadSafe = "I'm an instance variable" %>

Unless you know exactly what you are doing and you have a real good reason for doing so, never use instance variables. Declare all of your variables inside the service method and they will be tread safe.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!