2013-06-05 49 views
1

我在我的JSP定義爲輸入標籤:如何從JSP中刪除這個XSS?

<input type="text" name="transCurrency" maxlength="10" size="10" value="<%=beanUseVec.getValue("transCurrency")%>" /> 

相應的功能getValue()beanUseVec.java定義爲:

public String getValue(String vectK) 
{ 
    if(uEnVec != null && uEnVec.containsKey(vectK)) 
    return (String)uEnVec.get(vectK); 
    else 
    return ""; 
} 

當我做了veracode掃描我的文件,我發現XSS錯誤如下圖所示:

<input type="text" name="transCurrency" maxlength="10" size="10" value="<%=beanUseVec.getValue("transCurrency")%>" /> 

它指出<%=beanUseVec.getValue("transCurrency")%>是XSS風險。通常,對於JSP中的其他XSS風險,我使用jstl c:out標記,我認爲這個標記在這裏不能使用,因爲getValue()不是POJO函數,它只是一個返回字符串的函數,而c:out需要調用POJO函數的變量。

有人可以建議任何其他方式擺脫這個XSS的問題?

回答

1

能省則輸出到request變量和使用c:out標籤顯示它

<% 
String output = beanUseVec.getValue("transCurrency"); 
request.setAttribute("output",output); 
%> 

<input type="text" name="transCurrency" maxlength="10" size="10" value="<c:out value='${output}'/>"/> 
+0

謝謝你讓我檢查。 –

+0

非常感謝,它像一個魅力.Accepted和投票。 –

+0

我很高興它幫助:) – vjy