Solved

Passing variable to hidden field in JSP

Posted on 2007-03-29
5
359 Views
Last Modified: 2013-12-25
I am trying to pass the variable 'address' from a database to a hidden field for use in a JSP page. I cannot get this to work. and the value always turns up null. Some of what I am doing is shown below. How do I get address into the hidden value field as shown below? Can someone help?
...
ResultSet schoolRs = stmt.executeQuery("SELECT STU_NAME, STU_ADDRESS, GRADE_LEVEL WHERE...

String name;
String address;
String level;
       
      while(schoolRs.next() )
            {
            name = toolNameRs.getString("STU_NAME");
                address = toolNameRs.getString("STU_ADDRESS");
                level = toolNameRs.getString("GRADE_LEVEL");
     
                out.println(...do something...
}
     
%>
This is where I am having problems...
<input type="hidden" name="hidden" Value=' " + address + " '>
<%
          conn.close();
%>
0
Comment
Question by:ramoore
[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
  • 2
5 Comments
 
LVL 30

Accepted Solution

by:
Mayank S earned 125 total points
ID: 18818375
>> <input type="hidden" name="hidden" Value=' " + address + " '>

Is that in the JSP or are you generating that from a Servlet? If in a JSP, then it has to be:

<input type="hidden" name="hidden" Value="<%= address %>">
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18818651
mayankeagle's solution is right, but you shouldn't have a space character after <%=, the JSP compiler may fail to recognize the instruction:

<input type="hidden" name="hidden" Value="<%=address %>">
0
 

Author Comment

by:ramoore
ID: 18819008
Just what I needed. Thanks!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18819093
Thanks for the support elfe
0
 
LVL 11

Expert Comment

by:elfe69
ID: 18819143
You're welcome, I found that yesterday on another question...
0

Featured Post

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in Angular 2 when showing in grid 4 67
warning code: class php incomplete message 6 71
PHP Web Development 6 71
Display field if column exists 7 58
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

752 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