Solved

hidden fields in jsp

Posted on 2011-02-16
3
1,185 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 27

Accepted Solution

by:
rrz earned 250 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 250 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

Stack Overflow Podcast - Frustrating Miracles

In this podcast, Stack Overflow interviewed Linux Academy CEO/Founder, Anthony James, and got his developer story!

"Follow your passion, be prepared to work hard and sacrifice, and, above all, don't let anyone limit your dreams."  - Donovan Bailey

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

622 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