*
The moose likes JSP and the fly likes Question about _jspService thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Question about _jspService thread" Watch "Question about _jspService thread" New topic
Author

Question about _jspService thread

Adam Zedan
Ranch Hand

Joined: Jun 10, 2011
Posts: 124

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 ??

Don’t look where you fall, but where you slipped
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61309
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Jan 10, 2002
Posts: 61309
    
  66

Which, of course, is one the easiest ways to create threading problems in your application.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Bear Bibeault wrote:Which, of course, is one the easiest ways to create threading problems in your application.

INDEED
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about _jspService thread