Solved

Passing variable to hidden field in JSP

Posted on 2007-03-29
5
342 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
  • 2
  • 2
5 Comments
 
LVL 30

Accepted Solution

by:
mayankeagle 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:mayankeagle
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now