Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

hidden fields in jsp

Posted on 2011-02-16
3
Medium Priority
?
1,191 Views
Last Modified: 2012-05-11
<form method="post">

<select name ="getselected" id="getselected">
<option>fox</option>
<option>fox2</option>
<option>fox3</option>
</selected>

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

</form>




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
       variable
0
Comment
Question by:shragi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34908700
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");
0
 
LVL 28

Accepted Solution

by:
rrz earned 1000 total points
ID: 34909433
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" >
...
</select>
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 = 
              document.forms[0].selectedFile.options[document.forms[0].selectedFile.selectedIndex].value;
       document.forms[0].submit();
   }
</script>

Open in new window

0
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 1000 total points
ID: 34913592
if u want to set the values dynamically then u can use JSTL tag

Before loading the page jsut set the hiddenValue as blank

request.setAttribute("hiddenValue","");
In jsp
<input type="hidden" name="hiddenV" value="${hiddenValue}">
while changing the dropdown call some java script
set the value in java script function
document.forms[0].hiddenV.value=document.forms[0].getselected.value
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question