• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to show the previous values!

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[nonsense content deleted --bear]
[ November 10, 2003: Message edited by: Bear Bibeault ]
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes!! i missed the stmt statement..
thanks a ton everyone!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic