aspose file tools*
The moose likes JSP and the fly likes Scriplets - bad practise, why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Scriplets - bad practise, why?" Watch "Scriplets - bad practise, why?" New topic
Author

Scriplets - bad practise, why?

Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
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

Joined: Apr 21, 2006
Posts: 1847
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).


42
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Jan 10, 2002
Posts: 61238
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
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

Joined: Nov 30, 2004
Posts: 284

I wont forget some 4000 lines JSPs....
[ August 29, 2006: Message edited by: Oricio Ocle ]

SCJP, OCMJD, OCMJEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scriplets - bad practise, why?