facebook

JSP Formatter

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse Archived
  2.  > 
  3. Bugs
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #245965 Reply

    jleming
    Member

    When running a jsp format on the following code:

    
    <%@ page import="somestuff.*" %><%@ include file="/includes/globalstuff.jsp" %><%
    
      // some validation stuff
      if (notValid) {
        response.sendRedirect("someErrorPage.jsp");
      }
    
    %>
    

    I would get the following output:

    
    <%@ page import="somestuff.*" %>
    <%@ include file="/includes/globalstuff.jsp" %>
    <%
    
      // some validation stuff
      if (notValid) {
        response.sendRedirect("someErrorPage.jsp");
      }
    
    %>
    

    Which looks all nice and neat and all, but the problem comes with the compiled output of this file:

    
    /* jsp compiler specific code here...
    
    ... */
    import headerstuff.*;
    out.write("\n");
    // globalstuff included here
    out.write("\n");
    
    /* ... */
    
    if (notValid) {
      response.sendRedirect("someErrorPage.jsp");
    }
    
    /* ... */
    
    

    The problem with this is that since the JspWriter has already been committed (with the out.writes above), the response.sendRedirect may not work (this is compiler/server dependant, but with our server — which is particularly picky — this is not allowed at all).

    I agree that the formatted code looks nicer, but it does not work properly due to how it gets compiled. Is there a formatter option to fix this, or something to detect an out.write occurs before a response.sendError / sendRedirect / etc and flag that as a possible error?

    Thank You

    #245994

    Riyad Kalla
    Member

    I have to give you an award for most obscure bug of the year, this is certainly a doozy but I think the core problem here is it points out how fragile your solution is. Whenever a solution you are employing can be broken due to a format change I think it should raise a red light that something needs to change. I think you are lucky that you were smart enough to look at the compiled code and figure out why this is broken, but could you imagine handing this code off to a junior programmer to maintain? I imagine that could take them a week to figure out.

    Now if changing your approach is totally out of the question, unfortunately there is no switch to stop the formatter from doing this (right now atleast).

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: JSP Formatter

You must be logged in to post in the forum log in