Search code examples
javaformattingeclipse-luna

Eclipse EE format error


I am using Eclipse for Java EE developers, and I am getting this formatting error when pressing CTRL + SHIFT + F:

<%
    String loginError = (String) session.getAttribute("error");
        if (loginError != null) {
            session.removeAttribute("error");
            out.print(loginError);
        }
%>

The if statement has an extra TAB offset to the right. I want it like this:

<%
    String loginError = (String) session.getAttribute("error");
    if (loginError != null) {
        session.removeAttribute("error");
        out.print(loginError);
    }
%>

Question: How do I fix this, and make it format like in the example above?

Extra info:

  • I am using Eclipse Luna
  • This is happening in a .jsp file, opened with a JSP editor

Solution

  • It can depend on the exact version of the WTP Source editing jts.jsp you are using: there was a bug (bug 400297: JSP formatter breaks tab policy in scriptlet) which fixed it, but noticed another error: 400695: Extra indentation level when using spaces for the Tab policy

    The latter is still unresolved. Just for testing, you could try and set up the tab policy in Java,JSP,JS etc. editors/formatters to use tabs and not space, to see if that makes any difference.