SmarterThings.co.uk
Things... Smarter!
Subscribe to SmarterThings.co.uk RSS feedView a HTML version of the SmarterThings.co.uk RSS feedJava > JSP > 99 Bottles of Beer - Obfuscated
99 Bottles of Beer - Obfuscated
Vote for a 1 star ratingVote for a 2 star ratingVote for a 3 star ratingVote for a 4 star ratingVote for a 5 star rating
Avg: 3.0

Believe it or not, the following JSP code perfectly reproduces the "99 Bottles of Beer on the Wall" song, I entered this code onto the 99 Bottles of Beer website, and it is still awaiting submission. However, you can grab a copy of this code right now. This code is far from completely obfuscated, as it doesn't take a lot of figuring out, to work out how it works, but it is an example of making things harder for people to do.

<%String b[]={" bottle"," beer","<br>"," on the wall","no more","Take one down pass it around, "}; int x=99;while(x>0){int l=2;while (l>0){%> <%=x%><%=b[0]%><%=x!=1?"s":""%> of <%=b[1]%><%=l--==2?b[3]+", ":b[2]%><%}%> <%=b[5]%><%=--x>0?x+b[0]:b[4]+" "+b[0]%><%=x!=1?"s ":" "%>of<%=b[1]%><%=b[3]%>. <%=b[2]%><%=b[2]%><%}%> <%=b[4].substring(0,1).toUpperCase()+b[4].substring(1)%><%=b[0]%>s of<%=b[1]%><%=b[3]%>, <%=b[4]%><%=b[0]%>s of<%=b[1]%><%=b[2]%> Go to the store, buy some more, 99<%=b[0]%>s of<%=b[1]%><%=b[3]%>.<%=b[2]%>
Created by David Hayes on Fri, 27 Jan 2006 18:32:00