aspose file tools*
The moose likes JSP and the fly likes how to show the previous values! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to show the previous values!" Watch "how to show the previous values!" New topic
Author

how to show the previous values!

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
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

Joined: Mar 16, 2002
Posts: 11
[nonsense content deleted --bear]
[ November 10, 2003: Message edited by: Bear Bibeault ]

Learn more<br />SCJP2<br />IBM 483(J2EE) Test
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
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.


Malhar Barai
SOA & Java Book
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
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


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
yes!! i missed the stmt statement..
thanks a ton everyone!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to show the previous values!
 
Similar Threads
Changing the color of a String variable
J2EE and Servlets
Test cases for Action Class
JPA - Hibernate - query.getResultList() returns 3 null values.
login