2012-07-27 22 views
2

我需要爲jsp分配一個javascript變量。我通過在服務器中提交表單內的HTML隱藏字段來完成此操作。將JavaScript變量分配給jsp在同一頁面

但最後在jsp中的值是alwasy null。這些jsp代碼和javascript在同一頁面。請看看一個代碼:

<html> 
    <body> 
     <form action= "Custom_DHTMLDashboard_Content.jsp" method="post"> 
      <input type="hidden" id="hiddenField" /> 
      document.getElementById("hiddenField").value = reportID; 
      <input type="submit" value="Submit" /> 
     </form> 
    </body> 
</html> 

<%String MyID = (request.getParameter("hiddenField"));%> 
alert("this is scriptlet" + "<%=MyID%>");//always null 
+0

'alert(「this scriptlet」+「<%=MyID%>」); // always null' should also in'

相關問題