This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 187503 - JSP code formatter reformat
Summary: JSP code formatter reformat
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Windows 7 x64
: P2 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-12 07:21 UTC by grryf
Modified: 2010-07-30 03:07 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
JSP code before JSP formatter reformat (10.88 KB, application/octet-stream)
2010-06-12 07:21 UTC, grryf
Details
JSP code after JSP formatter reformat (7.45 KB, application/octet-stream)
2010-06-12 07:22 UTC, grryf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description grryf 2010-06-12 07:21:29 UTC
Created attachment 100033 [details]
JSP code before JSP formatter reformat

After automatic format (reformat) of JSP code.jsp my code is messy.
Comment 1 grryf 2010-06-12 07:22:46 UTC
Created attachment 100034 [details]
JSP code after JSP formatter reformat

JSP code after JSP formatter reformat
Comment 2 Tomasz Slota 2010-06-22 11:10:17 UTC
The issue is about formatting JSP scriptlets with nested JSP/HTML tags. Here is a simplified case extracted from the example submitted by the user:

<%
    String p = request.getParameter("p");
    if (p != null) {
        if (p.equals("podanie")) {
            %><%@ include file="index.jsp" %><%
        } else {
            %><%@ include file="index.jsp" %><%
        }
    } else {
        %><%@ include file="index.jsp" %><%
    }
%>


is formatted to:


<%
            String p = request.getParameter("p");
            if (p != null) {
                if (p.equals("podanie")) {
%><%@ include file="index.jsp" %><%                    } else {
%><%@ include file="index.jsp" %><%                    }
    } else {
%><%@ include file="index.jsp" %><%                    }
%>

This admittedly looks ugly. Grryf, before the issue is solved you may want to use the JSTL conditional tags (the use use of java scriptlets in JSP is obsolete and discouraged). The code would like this:

< %@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %>
<c:if test="${p != null}"> 
   <c:if test="${p == "podanie"}">
         <%@ include file="index.jsp" %>
   </c:if>    
</c:if> 

An even better idea would be to apply the "dispatcher view" pattern, see http://java.sun.com/blueprints/corej2eepatterns/Patterns/DispatcherView.html
Comment 3 David Konecny 2010-06-22 21:46:25 UTC
Tomasz, IMO this is Java problem - their formatter should be fixed.
Comment 4 Dusan Balek 2010-07-29 09:15:37 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/8c0331ab30b8
Comment 5 Quality Engineering 2010-07-30 03:07:17 UTC
Integrated into 'main-golden', will be available in build *201007300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8c0331ab30b8
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #187503: JSP code formatter reformat - fixed.