• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about _jspService thread

 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reading that once a jsp page becaomes a full servlet all the next incoming requests to that serlvet are run in a separate _jspService thread.
All the code in the jsp page scriptlet goes in the _jspService



I wanted to know that suppose a jsp page has a declaration tag such as <%! int i =0;%>
Now its equivalent code will be like



So the next time another request comes in for the same jsp page (Which is a servlet now) part of my code was the scriptlet and there was also a declaration tag. Now I wanted to get an idea of what really happens when the _jspService thread execute the second time does it ignore the declaration tag since it already exists ??
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scriptlets of any kind, especially declarations should no longer be used in modern JSP pages.

That said, declaration are evaluated at translation time and become part of the generated servlet at class level.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote: Now I wanted to get an idea of what really happens when the _jspService thread execute the second time does it ignore the declaration tag since it already exists ??

only one instance is created for a servlet class. hence the i is shared among threads/requests!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which, of course, is one the easiest ways to create threading problems in your application.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Which, of course, is one the easiest ways to create threading problems in your application.

INDEED
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic