• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scriplets - bad practise, why?

 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I have been reading around alot on how to present data on a JSP/html etc.

I was just wondering why do developers consider the use of scriplets to be bad practise? Surely when it comes to say looping/ organising presenting data they're great??

Thanks in advance

Regards
Zein
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, they're terrible.
Not only do they lead to extremely messy code, that code is also impossible to maintain by people who are not Java programmers.
JSP are meant for maintenance by website authors.

You can do everything you can with scriptlets by using custom tags, and much of what you can do with scriptlets you shouldn't be doing in the first place (like anything that's not purely presentation logic).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely when it comes to say looping/ organising presenting data they're great

People thought the same, at first. Because you can do anything. Anything from good things to bad things, especially bad ones for those who did not use scriptlets properly. I've seen jsp files full of scriptlet. A mess it is. Unreadable. From now on, keep it clean, with tags. There are great too.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's not forget about the lack of code reuse.

How the heck do you reuse a chunk of code inside of a scriptlet inside of a JSP. And 'cut and paste' doesn't count.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And let's not forget about testing.

Well, for code embedded in a JSP, you pretty much need to forget about testng!

At this point in the development of JSP as a technology, scriplets should be considered deprecated in favor of JSTL, EL and custom actions on your pages.

This article touches upon the progress of web application structural patterns.
 
Zein Nunna
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys,

I see your point re: scriplets.

Bear the article link you posted is awesome, alot to read, but absolutley fab, extremely informative.

I had a quick look at a JSTL tutorial, theres a mighty lot to learn !

I'm considering proceeding with my project as it is JSP/Servlets/Beans, to meet the deadline, and after that might phase in JSTL etc..JSF look nice too.

Thanks once again for the advice,
Regards
Zein
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wont forget some 4000 lines JSPs....
[ August 29, 2006: Message edited by: Oricio Ocle ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic