Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I know how JSPs convert to servlet?

 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
I think the topic of how JSPs convert to servlet is a background mechanism of JSP which programmers need not to consider in actual work. So need I know it to fit this certification?
Regards.
 
Sunil Vasudevan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need not know the internals for how a container converts JSP to a servlet. But you need to have an understanding of where and how the scriplets and expressions used in JSP fit into the servlet after translation. This is imp as based on these, the behaviour of the page changes.

Example:
If I have


The String name becomes an instance variable of servlet after conversion and hence not thread safe.

But if I update the above code to:


The String name becomes a member variable. Now it is thread safe.

This is the kind of understanding of JSP to servlet conversion one should have. Of course, I have just given one example. There are more to it which any study guide would touch upon.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sunil,
Thanks for your reply.
One question:
What's the difference between an instance variable of servlet and member variable?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He means :
an instance variable of servlet : a member of the servlet class
a member variable : a variable local to the function
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic