943,875 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 18199
  • JSP RSS
Feb 9th, 2007
0

jsp code for values from database to textbox

Expand Post »
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>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vasudha k is offline Offline
17 posts
since Feb 2007
Feb 9th, 2007
0

Re: jsp code for values from database to textbox

JSP is very bad choise for setting connection to database you better do it in servlet/front controler

then in JSP just say

JSP Syntax (Toggle Plain Text)
  1. <textarea rows="10" cols="30"> <%=stringToDisplay%></textarea>
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Sep 28th, 2009
0

Re: jsp code for values from database to textbox

Click to Expand / Collapse  Quote originally posted by peter_budo ...
JSP is very bad choise for setting connection to database you better do it in servlet/front controler

then in JSP just say

JSP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
karpaklu is offline Offline
10 posts
since Jul 2009
Sep 28th, 2009
-1

Re: jsp code for values from database to textbox

Click to Expand / Collapse  Quote originally posted by karpaklu ...
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...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Mar 22nd, 2010
0
Re: jsp code for values from database to textbox
Click to Expand / Collapse  Quote originally posted by peter_budo ...
Maybe I can help if you post your code...
you have to use the values tag in the text area for setting the textboxes.

eg

<input type=text values=<%=string%> ......
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raj_predators@y is offline Offline
1 posts
since Mar 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: how to create a jsp page
Next Thread in JSP Forum Timeline: Save to excel-take path from user





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC