hidden fields in jsp

<form method="post">

<select name ="getselected" id="getselected">

<input type="hidden" name="hidden" value="<%=getselected%>">


on server side

String selectedvalue = (String)request.getParameter("hidden");

when i use hidden field in jsp it showed me an error

Multiple annotations found at this line:
      - Tag (input) should be an empty-
       element tag.
      - getselected cannot be resolved to a
Who is Participating?
rrzConnect With a Mentor Commented:
I have been reading your other questions. This a javascript question.  
If your hidden field in your form is
<input type="hidden" name="fileLocation" value="not yet">
and you have
 <select name="selectedFile" >
and you have
<input class="button" value="Submit" type="button" onclick="performAction2()" />
then your script will be  
<script language="JavaScript" type="text/javascript">
   function performAction2() {
       document.forms[0].fileLocation.value = 

Open in new window

Sathish David Kumar NArchitectCommented:
while loading the page <%=getselected%> is null so that only its give error more over you cant get that value directly .

try this

String selectedvalue = (String)request.getParameter("getselected");
Sathish David Kumar NConnect With a Mentor ArchitectCommented:
if u want to set the values dynamically then u can use JSTL tag

Before loading the page jsut set the hiddenValue as blank

In jsp
<input type="hidden" name="hiddenV" value="${hiddenValue}">
while changing the dropdown call some java script
set the value in java script function
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.