File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Lost in a Sea of Scriptlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Lost in a Sea of Scriptlets" Watch "Lost in a Sea of Scriptlets" New topic
Author

Lost in a Sea of Scriptlets

Cory Hartford
Ranch Hand

Joined: May 16, 2011
Posts: 82

Hi Everyone. I have been tasked with maintaining a system that is full of Scriptlets and was first written somewhere around the year 2000. I've worked with SE for quite a while but this is my first professional foray into the presentation layer. I have a very specific feature set to add to a very big system that is written in this way and I wanted some advice on what the right thing to do is. Obviously I have to maintain a schedule and trying to bring everything up to date isn't feasible. I believe a good middle ground is to try and use backing beans and EL (as opposed to trying to move to Struts 2 or Faces) on the areas I am touching. But I am struggling to try and figure out a path forward; I am concerned that I might end up in a refactoring spiral that won't end or breaking something in another area since everything is so tightly coupled. I have read some about preprocessor servlets that can be pointed at the JSP, but given how intertwined all of these scriptlets are I'm not sure that will move me in the right direction. My other option is to try and do the best I can and move forward with well written scriplets. I've read enough of Bear's posts that I know that's not the best way to go, but I'm not sure if I have a choice. Thanks very much for any advice. Here is an excerpt; this is common throughout the system; probably 2 or 300 JSPs written in this fashion.



‎"The greatest of all weaknesses is the fear of appearing weak." - JB Bossuet
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

What you did not mention is why you need to touch these JSPs. Do you need to add lots of new functionality? Fix minor bugs? Or is it that their mere existence violates your sensibilities?

For the former, I'd consider refactoring. For the middle, it depends. For the latter, I'd not touch what isn't broken (as much as that violates my sensibilities).

Dealing with legacy systems is never fun.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Cory Hartford
Ranch Hand

Joined: May 16, 2011
Posts: 82

Bear Bibeault wrote:What you did not mention is why you need to touch these JSPs. Do you need to add lots of new functionality? Fix minor bugs? Or is it that their mere existence violates your sensibilities?


Well number one; I have to add a fairly significant feature set, but I think its going to be a bunch of small touches in a lot of different areas if that makes any sense. And number two, because I've read enough of the Ranch forums and Uncle Bob's books that it feels like I am doing evil. Blech.
I guess I'll forge ahead and try to implement best practices where I can. By the end I should well versed on what not to do. Kind of like a field trip to a prison; I'll be scared straight.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

Cory Hartford wrote:Well number one; I have to add a fairly significant feature set, but I think its going to be a bunch of small touches in a lot of different areas if that makes any sense.

Yeah, much as I hate to say it, it sounds like you might be best served by leaving well enough alone, and trying to make the JSPs as clear as possible within the limitations of the technology.

That is unless things reach a tipping point where it becomes less of a hassle to just Etch-A-Sketch a page and start over than to try and deal with a huge mess that just breaks every time you breathe near it. If your posted example is representative, things may not come to this. It looks as if the scriptlets are pretty much limited to control statements and data fetching/expressions. Things get much worse when there are large blocks of inappropriate functionality.

Of course, any new JSPs are a different matter.

By the end I should well versed on what not to do. Kind of like a field trip to a prison; I'll be scared straight.
Cory Hartford
Ranch Hand

Joined: May 16, 2011
Posts: 82

Thanks very much for the advice Bear.
 
GeeCON Prague 2014
 
subject: Lost in a Sea of Scriptlets