Input value from SQL database into html Form
I was new to jsp and want to make update page for my website, i want to pun value in my html form from table. i using JSP.
JDBC Connection
ResultSet rs2 = stmt2.executeQuery("Select * from securityDetails );
-html textbox--
<form name="f1" action="prosesmyprofile.jsp" method="get" onsubmit="return validate(this.form)" >
<input type="text" name="IDForm" value="<%=request.getParameter("+fromdatabase+")%>" >
-jsp Taq
while(rs.next()||rs1.next()|| rs2.next())
{
String uname=rs2.getString("columinDatabase");
}
-
the result is NULL went i refresh my page..can any want tell me..i want to make update profile page just like friendster with value in the box
[744 byte] By [
Maxcorda] at [2007-11-27 11:03:06]

# 2
in the HTML form the out put is Null,
its look lke its cannnot get data from database
i just like to use Update page just like friendster, but friendster is using Php.
# 3
<%
while(rs.next()||rs1.next()|| rs2.next())
{
String uname=rs2.getString("columinDatabase");
%>
<input type="text" name="name" value="<%=uname%>" />
<%
}
%>
JSP code should be embeded using <% and %>
Good Luck
Ranjith
# 4
i still have error like this->Undefined variable: uname out.print(uname);<--this statement out
It said my variable do not undefied..i all ready define its like this
--
String uname=rs.getString("columninDatabse");
-
should all this is one <%%>
# 5
Try this:
<%
String uname;
while(rs.next()||rs1.next()|| rs2.next())
{
uname=rs2.getString("columinDatabase");
%>
<input type="text" name="name" value="<%=uname%>" />
<%
}
%>
NB: You will get multiple input text fields with the same name and id ! I don't think that this is what you want..
take a look at:
http://java.sun.com/products/jsp/syntax/2.0/syntaxref20.html
http://java.sun.com/products/jsp/syntax/2.0/syntaxref204.html#10983
http://java.sun.com/products/jsp/syntax/2.0/syntaxref205.html#1004353
http://java.sun.com/products/jsp/syntax/2.0/syntaxref206.html#10996
Hope That Helps
# 6
<%
while(rs.next()||rs1.next()|| rs2.next())
{
String uname=rs2.getString("columinDatabase");
%>
<input type="text" name="name" value="<%=uname%>" />
<%
}
%>
try this one .....
<input type="text" name="name" value="${pageScope.uname}/>
if you get any error
use this
<input type="text" name="name" value="${uname}/>">