This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Building HTML Controls On The Fly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Building HTML Controls On The Fly" Watch "Building HTML Controls On The Fly" New topic
Author

Building HTML Controls On The Fly

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
I need to create some HTML TEXT controls in a loop that will display the contents of a result set.
Below is what I came up with. This displays an empty TEXT field, but no data. I checked and the rs.getString(item) is returning some string data.
Can anybody tell me what change I need to make to the text below so it'll print out the rs.getString(item)>?
Thanks much.
-----------------------
out.println("<p><INPUT TYPE=TEXT, NAME= " + namVar + "VALUE= " + rs.getString(item)+"<p>");
(???)
George Larry
Ranch Hand

Joined: Nov 07, 2001
Posts: 52
Try this:

ITEM should be the name of the column in the db. (SELECT ITEM FROM TABLE), alternatively you can do this rs.getString( 1 ) which will return the 1st column your query returns.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
Yes, this worked after I uncommented "ITEM".
Thank you very much!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Building HTML Controls On The Fly
 
Similar Threads
Problem getting result on Page
Could it be Tomcat; I cant get my result on the screen
Problem getting result on Page
SQL coding to add stock balance in JSP
getting null parameters in post