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

x
?
Solved

Passing variable to hidden field in JSP

Posted on 2007-03-29
5
Medium Priority
?
366 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 500 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

705 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