Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to show the previous values!

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ima trying to create a jsp file where users can edit their previously stored profiles which they save when they sign up for registration..
well the profile gets updated but i want that the as the users click on the edit link the edit page should show in all the textfields the previously stored values..
but iam not able to achieve success in the same..
can anyone try to figure out what went wrong??
here is the code:
in the body tag:
<%
Connection con=null;
java.sql.Statement stmt=null;
ResultSet rs=null;
boolean y=false;
int i;
String username=(String)session.getAttribute("y");
String name="";
String lname="";
String addr="";
String ct="";
String st="";
int pincode=0;
int phone=0;
String em="";
System.out.println(username);
System.out.println(name);
System.out.println(lname);
if (username == null )
username="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
rs=stmt.executeQuery("select fname,lname,address,city,state,pincode,phone,email from personal_info where user_login='"+username+"'");
if(rs.next())
{
name=rs.getString("fname");
lname=rs.getString("lname");
addr=rs.getString("address");
ct=rs.getString("city");
st=rs.getString("state");
pincode=rs.getInt("pincode");
phone=rs.getInt("phone");
em=rs.getString("email");
}
}
catch(Exception e)
{
System.out.println("exception in block"+e);
}
System.out.println("name="+name);
System.out.println("lname="+lname);
System.out.println("addr="+addr);
System.out.println("ct="+ct);
System.out.println("st="+st);
System.out.println("pincode="+pincode);
System.out.println("phone="+phone);
System.out.println("email="+em);
%>
in the form fields :
<p><font face="Georgia, Times New Roman, Times, serif">First Name  </font> <font face="Georgia, Times New Roman, Times, serif"><input name="fname" type="text" align="right"
value="<%= name%>">    
thanks all
jyotsana
 
Sohail Ahmed
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[nonsense content deleted --bear]
[ November 10, 2003: Message edited by: Bear Bibeault ]
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
What is stmt, there's no statement like

hth
MB
p.s. always use UBB Code to show your codes, so as to preserve code-formatting.
 
Praful Thakare
Ranch Hand
Posts: 642
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sohil,
WellCome to EARTH,It will be our pleasure to know your planet.
And v will be gratefull if you can comunicate in Language spoken on Earth .
=============================================================
Jyotsana,
I guess you are getting NullPointer Exception,check your tomcat prompt.
You missed stmt=con.createStatement(),before,
rs=stmt.executeQuery("select fname,lname,address,city,state,pincode,phone,email from personal_info where user_login='"+username+"'");
Cheers
Praful
 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes!! i missed the stmt statement..
thanks a ton everyone!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic