Solved

Passing variable to hidden field in JSP

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

628 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