Head-meet-desk moment



  • In the process of helping a coworker resolve an issue involving the generation of XML content from a JSP (yes, yes, I know that's TRWTF), I discovered he had attempted to render JavaScript in the XML output as a "way" of solving his problem. Before you ask: no, the client system which will be processing the generated XML will not parse or interpret JavaScript submitted in the XML and it certainly won't get evaluated on the server-side. He was somehow expecting that the JavaScript would be magically evaluated allowing him to solve his problem because he couldn't figure out how to do what needed to be done using the available Java objects and JSTL.

    I had my doubts about this particular coworker, but this goes way beyond anything I'd imagined.



  • Hmmm, not a bad idea... Would it have worked?

    I wanted to coin JXML as a new acronym, but it already exists.



  • @b_redeker said:

    Hmmm, not a bad idea... Would it have worked?

     

    Even if the client or the server were setup to evaluate the embedded JavaScript it would not have worked. The problem was in getting the right information from the database (i.e. using the right Java objects to access the data), so I can't imagine how he thought JavaScript would solve the problem.



  • @DeepThought said:

    I can't imagine how he thought JavaScript would solve the problem.

     

     

    What, you mean you never heard of the [url=http://thedailywtf.com/Articles/Straight_Shooter_for_Upper_Management.aspx]"Have you tried JavaScript?"[/url] meme yet?



  • @C4I_Officer said:

    What, you mean you never heard of the "Have you tried JavaScript?" meme yet?

     

     No I've only in the past year started to read the posts on this site with any regularity, but I appreciate the heads-up.



  • @DeepThought said:

    generation of XML content from a JSP (yes, yes, I know that's TRWTF)
    Nothing terribly wrong with that.  a POJO would be better, but it could be done in a JSP if you completely ignore the purpose of a JSP.

    OK Fine, yeah, it is a terrible idea.



  • @belgariontheking said:

    @DeepThought said:

    generation of XML content from a JSP (yes, yes, I know that's TRWTF)
    Nothing terribly wrong with that.  a POJO would be better, but it could be done in a JSP if you completely ignore the purpose of a JSP.

    OK Fine, yeah, it is a terrible idea.

    I have no problem with using a JSP for an XML document that's just a series of records or something that can be looped through and generated on the fly.  It's easier than building a node tree and outputting it to a file, and less hideously ugly than using lots of StringBuilder.


  •  @belgariontheking said:

    Nothing terribly wrong with that.  a POJO would be better, but it could be done in a JSP if you completely ignore the purpose of a JSP.

    OK Fine, yeah, it is a terrible idea.

    In this case it's a matter of expediency. The application being modified already comes supplied with many JSPs used to generate XML for the purposes of serving AJAX type requests. This particular JSP is being implemented for very similar purposes, so it was simply quicker and easier to implement this using a JSP. Not ideal to be sure, but not a real stretch to implement in JSPs since XML and HTML are practically kissing cousins. I've seen far worse basterdizations of JSP, but I'm still floored that the developer in question thought that by including JavaScript embedded in script tags within the JSP that this would magically cause the JavaScript to get evaluated.

    @bstorer said:

    It's easier than building a node tree and outputting it to a file, and less hideously ugly than using lots of StringBuilder.

    I agree.



  • @DeepThought said:

    I'm still floored that the developer in question thought that by including JavaScript embedded in script tags within the JSP that this would magically cause the JavaScript to get evaluated.
    You know what I just thought?  I'm sure we all thought it, but I bet he thought JS was part of JSP.  You know, since if you write it out, you have to write JS to write JSP.

    I'm going with that.



  • @belgariontheking said:

    @DeepThought said:

    I'm still floored that the developer in question thought that by including JavaScript embedded in script tags within the JSP that this would magically cause the JavaScript to get evaluated.
    You know what I just thought?  I'm sure we all thought it, but I bet he thought JS was part of JSP.  You know, since if you write it out, you have to write JS to write JSP.

    I'm going with that.

     

    Thanks, I needed a laugh.



  • @DeepThought said:

    In the process of helping a coworker resolve an issue involving
    the generation of XML content from a JSP (yes, yes, I know that's
    TRWTF), I discovered he had attempted to render JavaScript in the XML
    output as a "way" of solving his problem. Before you ask: no, the
    client system which will be processing the generated XML will not
    parse or interpret JavaScript submitted in the XML and it certainly
    won't get evaluated on the server-side. He was somehow expecting that
    the JavaScript would be magically evaluated allowing him to solve his
    problem because he couldn't figure out how to do what needed to be
    done using the available Java objects and JSTL.

    I had my doubts about this particular coworker, but this goes way beyond anything I'd imagined.

    Sounds like JSON and date handling. That might be where he got the idea, but... sadly I doubt it.



  • @belgariontheking said:

    @DeepThought said:

    I'm still floored that the developer in question thought that by including JavaScript embedded in script tags within the JSP that this would magically cause the JavaScript to get evaluated.
    You know what I just thought?  I'm sure we all thought it, but I bet he thought JS was part of JSP.  You know, since if you write it out, you have to write JS to write JSP.

    I'm going with that.

     

    Dude JS is part of JSP... JSp duh! Oh wait JavaScript vs Java Servlet Pages... both got java! C'mon its gota be in the same neighborhood.

     

    What really scares me is that Javascript can do things java can't... Please give an example O great OP because now my curiosity has spiked. Also audio record his descriptions so we can all share in the good times and laughter.



  • @astonerbum said:

    What really scares me is that Javascript can do things java can't... Please give an example O great OP because now my curiosity has spiked. Also audio record his descriptions so we can all share in the good times and laughter.

     

    <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"><title></title><meta name="GENERATOR" content="OpenOffice.org 3.0 (Win32)"><style type="text/css"> </style>

    At the point where I discovered that the other developer had tried to make use of JavaScript, I recall asking him why he thought using JavaScript would fix the problem. All I could make out from his stammering response was that he couldn't get the page to work using JSTL, so he thought using JavaScript might help. I dropped the questioning at that point out of concern that I'd say or do something I might regret later. Perhaps one day I'll bring up the topic again and see if I can get a somewhat coherent explanation.



  • @DeepThought said:

    Perhaps one day I'll bring up the topic again and see if I can get a somewhat coherent explanation.
    People who attempt to solve XML problems using Javascript are unlikely to be capable of coherent explanations.



  • document.write("I tried to explain it to you ");

    document.write(14);

    document.write(" times but you wouldn't listen.");


Log in to reply