JSP Code
Rules available in this category:
- Avoid_duplicate_JSP_local_variable_names
- Cyclic_include_of_JSPs
- Avoid_duplicate_JSP_field_names
- Avoid_duplicate_JSP_imports
- Avoid_duplicate_JSP_method_names
- Never_use_reserved_JSP_local_variable_names
- Always_provide_JSP_headers_comments
Rule 1: Avoid_duplicate_JSP_local_variable_names
Severity:
Critical
Rule:
Avoid duplicate local variable names in JSP. This can happen when other JSPs are included.
Reason:
Avoid duplicate local variable names in JSP. This can happen when other JSPs are included.
Usage Example:
one.jsp
<%@ include file="two.jsp" %>
<%
int var = 0; // VIOLATION
%>
two.jsp
<%
int var = 0;
%>
Should be written as:
Reference:
Rule 2: Cyclic_include_of_JSPs
Severity:
Critical
Rule:
Detects the infinite loop caused by including JSPs.
Reason:
Detects the infinite loop caused by including JSPs.
Usage Example:
one.jsp
<%@ include file="two.jsp" %>
...
two.jsp
<%@ include file="three.jsp" %>
...
three.jsp
<%@ include file="one.jsp" %>
...
Should be written as:
Reference:
Rule 3: Avoid_duplicate_JSP_field_names
Severity:
Critical
Rule:
Avoid duplicate field names in JSP. This can happen when other JSPs are included.
Reason:
Avoid duplicate field names in JSP. This can happen when other JSPs are included.
Usage Example:
one.jsp
<%@ include file="two.jsp" %>
<%!
int fld = 0; // VIOLATION
%>
two.jsp
<%!
int fld = 0;
%>
Should be written as:
Reference:
Rule 4: Avoid_duplicate_JSP_imports
Severity:
High
Rule:
Avoid duplicate imports in JSP.
Reason:
Avoid duplicate imports in JSP.
Usage Example:
<%@ page import=\"com.foo.MyClass,com.foo.MyClass\"%> // VIOLATION
//...
Should be written as:
<%@ page import=\"com.foo.MyClass\"%> // FIXED
//...
Reference:
Not Available.
Rule 5: Avoid_duplicate_JSP_method_names
Severity:
Critical
Rule:
Avoid duplicate methods in JSP. This can happen when other JSPs are included.
Reason:
Avoid duplicate methods in JSP. This can happen when other JSPs are included.
Usage Example:
one.jsp
<%@ include file="two.jsp" %>
<%!
public void foo() // VIOLATION
{
...
}
%>
two.jsp
<%!
public void foo() // VIOLATION
{
...
}
%>
Should be written as:
Reference:
Rule 6: Never_use_reserved_JSP_local_variable_names
Severity:
Critical
Rule:
Never use local variable names used by servelts, since this can result in duplicate variable names.
Reason:
Never use local variable names used by servelts, since this can result in duplicate variable names.
Usage Example:
one.jsp
<%
int request = -1; //VIOLATION
%>
Should be written as:
Reference:
Rule 7: Always_provide_JSP_headers_comments
Severity:
Medium
Rule:
Never use local variable names used by servelts, since this can result in duplicate variable names.
Reason:
Never use local variable names used by servelts, since this can result in duplicate variable names.
Usage Example:
<html>
<head>
<title>Notice and Result</title>
</head>
<body topmargin=0>
....
</body>
</html>
Should be written as:
<%-- This JSP displays the login form --%>
<html>
<head>
<title>Notice and Result</title>
</head>
<body topmargin=0>
....
</body>
</html>
Reference: