Get a parameter in a TextField
Hello everyone,
I have a JSP file from where a calling another JSP...
first thing i do in calling the other JSP is sending the parameter from a hyperlink like this:
-out.println("<tr><td><a href =DataInput.jsp?para=" + pers +">"+ pers +"</a>
result;
http://...../Task/DataInput.jsp?para=32
it works fine!
The other JSP opens and i ask for the parameter like this:
-String value1=request.getParameter("para");
OK!next...
Now i want to retrieve a row from a database
<%...
ResultSet rs = stmt.executeQuery("SELECT *FROMCalc WHERE PersID =" + value1 );
....%>
OK!untill here....
Now i want to display the data(row) i got back from the DB in the textfields of the current JSP.
These textfields are defined as followed:
-<input type="text" name="fname" size=25>
....this is just one i have 6(different) of this fields
Now what's the trick to get the data of my row in to the Textfields?
i have searched the whole site... for this matter...but..!!!!
Is there a solution...for this problem?
Thanks for helping me out!!!
best regards,
stoneJ
[1242 byte] By [
stoneJ] at [2007-9-26 1:40:03]

stonej -
I am assuming that everthing you are doing is in jsp....right?
I don't work that much with result sets -- I use the borland querydataset stuff, but it should be pretty similar...so take my syntax with a grain of salt.
In the jsp page just say:
<%=rs.getString("DBCOLUMNNAME")%>
So what I am doing is telling the page to get a string (use the appropriate data type you want, from the result set, with that name....you might have to use an integer there that describes the location of the column within the result set. You might also have to say something like <%rs.next()%> first, because I think the result set cursor starts out somewhere before the first record.
Hope this helps.
Tim C.
Hi Tim,
Thats the part i already figured out..
and yes i only work with JSP...
The real problem is getting the data in to the textfield
(syntax to refer to the textfield)....
<% ?=rs.getString("DBCOLUMNNAME")%>
the syntax before '=' how do i refer to the name of
the TextField(i already tried the setText() method,but without succes...
Thanks!
Best regards,
stoneJ
stonej -
Oh.... What I gave you would only write the value like a label on the jsp page.
Here's a text field right out of one of my jsp pages:
<input type="text" name="email" size="21" value="<%=cust.getEmail()%>">
For the value property, you could just substitute whatever you are grabbing from your result set.
Tim