Scriptlets in JSPs or HTML inside Servlets?

January 20, 2007

Neither, please!

In case you wondered, yeah we have both.
I was terribly annoyed by the amount of logic inside the JSPs I’m refactoring for our company’s web app. I was ranting out to Ozzie, so he asked me that question. Fine, fine, fine! Refactoring Servlets which generate HTML is definitely worse than refactoring JSPs with a ton of scriptlets.

This one cracked me up, though (I laughed so hard, but at the same time I wanted to crack my head open). What will you do when you find code like this?

<!–Scripting elements, directives, actions, Template text, JSTL (if you’re lucky), and what-have-you’s–>

<%
for (int i21=0;i21<dft21.length;i21++)
{
String thisUrl21 = dft21[i21].getURL();
StringBuffer buf83 = new StringBuffer();
StringBuffer buf84 = new StringBuffer();
if (thisUrl21 != null)
{
buf83.append(“<a href=\”");
buf83.append(thisUrl21);
buf83.append(“\” target=\”_blank\”>”);
buf84.append(“</a>”);
}
%>
<%=buf83.toString()%>
<%– some other things (scriptlets & template text) inside the link –%>
<%= buffer84.toString()%>
<%}%>

<!–Scripting elements, directives, actions, Template text, JSTL (if you’re lucky), and what-have-you’s–>

No, dont mind the obscure naming and seemingly random numbers appended to them. JSPs with scripting elements that generate HTML? Oh, this is just so awful! (Mind you, I had to format the code too. It was like they really made it so that the code would be as unreadable as possible)

Hopefully this refactoring and replatforming will get these ‘wtf codes’ out of our system. Here’s hoping! :)

Entry Filed under: Daily Geekiness, Random thoughts. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


 

January 2007
S M T W T F S
« Dec   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031  

a

Blogroll

Ozzie

Feeds

Recent Posts

Archives