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