Solved

Passing variable to hidden field in JSP

Posted on 2007-03-29
5
346 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:
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

932 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

10 Experts available now in Live!

Get 1:1 Help Now