HTML で JSP を使用して、別のページに送信するフォームがあります。フォームには、複数の要素を持つ選択リストがあります。フォームを送信する前に、java スクリプトで、リスト内のすべての要素が選択されていることを確認します。次に、フォームを次のページに送信します。次のページでは、リストで選択した値を Java 配列に割り当てます。配列のサイズまたはその配列内の任意の値を表示しようとすると、Null Pointer Exception が発生します。
リストを含む私のフォームは次のとおりです。
<form name="inputGenesForm" id="test" method="POST" ACTION="result.jsp" enctype="multipart/form-data">
<div style=" position:absolute;top:6%;left:39%;">
...
...
<select id="inputSet2" multiple="multiple" style="position:absolute; top: 93px; left: 270px; width: 200px; height: 200px;">
result.jsp では、
<body background="image/geneBG.jpg">
<%
String [] selectedGenes= request.getParameterValues("inputSet2");
%>
<script>
alert(<%=selectedGenes.length%>);
</script>
誰でも助けることができますか?ありがとうございました。
フォームを result.jsp に送信する際のエラー:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.