1

In the JSP development community, there's a broad consensus that use of scriptlets (Java code written directly in a .jsp page within <% %> tags) is a very poor development practice. (For example, see this popular question: How to avoid Java code in JSP files?.)

However, in ASP.NET, there seems to be no such broad negative opinion regarding reasonable/limited use of embedded code blocks of C# (or other CLR language) code in <% %> tags in .aspx pages.

Apart from the obvious simple observation that JSP and ASP.NET are different platforms, what reasons account for this difference? (Is it because some modern features of JSP such as JSTL, which enable use of scriptlets to be avoided, don't have equivalents in ASP.NET?)

Community
  • 1
  • 1
Jon Schneider
  • 25,758
  • 23
  • 142
  • 170
  • I can't speak for the Java technologies in question, but for ASP.NET I'd say it depends on the code within those blocks. If it's a lot of code doing any sort of calculations, it's probably best to move it out of the page/view/etc. If it's just emitting a value to the page/view/etc. from some backing model/object/etc. then that's fine. – David Jul 02 '14 at 19:12

0 Answers0