jsp code for values from database to textbox

Thread Solved

Join Date: Feb 2007
Posts: 17
Reputation: vasudha k is an unknown quantity at this point 
Solved Threads: 0
vasudha k vasudha k is offline Offline
Newbie Poster

jsp code for values from database to textbox

 
0
  #1
Feb 9th, 2007
Can anyone help me out ?.......
I have written a code for a form. the first five fileds in the form must be filled automatically by capturing the user id from login page.
I have been able to capture the data and print it on the screen
But, Iam not able to put those values in the textbox
Iam pastin the copy of my code.................
Please help me out ................

Iam getting an exception when i write value=<%=id%> for the text box value . It says id is not declared


<%@ page language="java" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<%
String id , name , dept, desig,band;
String username=(String) session.getAttribute("theName");
if(username==null) username="";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin192.168.150.252:1521:xdevload","xius","xius");
out.println("connection established");
String s ="select emp_id , emp_name ,emp_dept_id, emp_desig_id, band_id from employee_master where emp_id=(select user_id from user_master where user_name='"+username+"')";
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery(s);
out.println("data retrieved");
while(rs.next())
{
id = rs.getString(1);
name=rs.getString(2);
dept=rs.getString(3);
desig=rs.getString(4);
band=rs.getString(5);
out.println(id+" "+name+" "+dept+" "+desig+" "+band);

}
}
catch(Exception e)
{
}
%>
<!--
<BODY>
<center>
<form name="form1">
EMP ID <input type="text" name="text1">
<br>
EMP name <input type="text" name="text2">
<br>
EMP designatiom <input type="text" name="text3">
</form>
</center>
</BODY>-->
</HTML>
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,285
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: jsp code for values from database to textbox

 
0
  #2
Feb 9th, 2007
JSP is very bad choise for setting connection to database you better do it in servlet/front controler

then in JSP just say

  1. <textarea rows="10" cols="30"> <%=stringToDisplay%></textarea>
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 10
Reputation: karpaklu is an unknown quantity at this point 
Solved Threads: 0
karpaklu karpaklu is offline Offline
Newbie Poster

Re: jsp code for values from database to textbox

 
0
  #3
Sep 28th, 2009
Originally Posted by peter_budo View Post
JSP is very bad choise for setting connection to database you better do it in servlet/front controler

then in JSP just say

  1. <textarea rows="10" cols="30"> <%=stringToDisplay%></textarea>
hello peter
i just tried with the above statement to set value inside the textbox,
but wats happening is the value is been displayed outside the textbox.can u help me?

thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,285
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: jsp code for values from database to textbox

 
-1
  #4
Sep 28th, 2009
Originally Posted by karpaklu View Post
hello peter
i just tried with the above statement to set value inside the textbox,
but wats happening is the value is been displayed outside the textbox.can u help me?

thanks in advance
Maybe I can help if you post your code...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 8799 | Replies: 3
Thread Tools Search this Thread



Tag cloud for JSP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC