Getting Textbox data from database
When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown below.
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /raisereq.jsp:72
<tr>
<td width="108">Name:</td>
<td width="185"><label>
<input type="text" name="fname" value="<%=rs.getString(1)%>" readonly/>
</label></td>
</tr>
<tr>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
javax.servlet.ServletException: Invalid column index
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.raisereq_jsp._jspService(raisereq_jsp.java:175)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.sql.SQLException: Invalid column index
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:379)
org.apache.jsp.raisereq_jsp._jspService(raisereq_jsp.java:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.35 logs.
Apache Tomcat/5.5.35
My Code is:.
<%
String empid=(String) session.getAttribute("empid");
ResultSet rs=null;
Statement stmt=null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","adm","adm");
stmt=con.createStatement();
rs=stmt.executeQuery("select fname,empid from cremp where empid='"+empid+"'");
rs.next();
}
catch(Exception e){}
finally {
rs.close();
stmt.close();
}
%>
<table width="309" border="1" align="center">
<tr>
<td width="108">Name:</td>
<td width="185"><label>
<input type="text" name="fname" value="<%=rs.getString(1)%>" readonly/>
</label></td>
</tr>
<tr>
<td>Id:</td>
<td><label>
<input type="text" name="empid" value="<%=rs.getString(6)%>" readonly/>
</label></td>
</tr>
View Answers
September 22, 2012 at 5:22 PM
Here is a jsp code that retrieves data from database and display it on the textboxes.
<%@page language="java"%>
<%@page import="java.sql.*"%>
<table border="1">
<%
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='1'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
if(rs.next()){
%>
<tr>
<tr><td>Name</td><td><input type="text" name="name" value="<%=rs.getString("name")%>"></td></tr>
<tr><td>Address</td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Contact No</td><td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td></tr>
<tr><td>Email</td><td><input type="text" name="email" value="<%=rs.getString("email")%>"></td></tr>
<%
}
}
catch(Exception e){}
%>
</table>
Related Tutorials/Questions & Answers:
Getting Textbox data from databaseGetting Textbox data from database When i m trying to get
data in
textbox as readonly
from database i m
getting following error.and my code is shown...
data from database and display it on the textboxes.
<%@page language="java
Getting Textbox data from databaseGetting Textbox data from database When i m trying to get
data in
textbox as readonly
from database i m
getting following error.and my code is shown...;Here is a jsp code that retrieves
data from database and display
Advertisements
How to show data from database in textbox in jsp How to show
data from database in
textbox in jsp How to show
data from database in
textbox in jsp
Here is an example that retrieve the particular record
from the
database and display it in
textbox using JSP.
<
Dynamically Update textbox from databaseDynamically Update
textbox from database I have a
database as shown below.(
database created using SQL Server 2005)
name : george,simon
address... to that typed value
from database has to be displayed in another text box
Getting data from servlet into javascriptGetting data from servlet into javascript How do i get json
data from my servlet on to a variable in javascript n bind the
data to display onto sigma grid.Has anyone Idea how to do
retrive data from database?retrive
data from database? hellow
i have a
database sheet name..... now i want retrive sn,roll no and name and
textbox
like...
from db1 and enter value in text box according there name,rollno and save
getting values from database - JSP-Servletgetting values
from database I tried the following code
abc.html
aaa.jsp
I am not
getting exceptions now. But I am not
getting output also.
Plz help.
Hi Friend,
Run your
How to Retrieve data from database in jspHow to Retrieve
data from database in jsp
In this section we will discuss about how to fetch
data from database table.
We will give a simple example which will demonstrate you about fetching
data
from database table.
Example
We
selecting data from databaseselecting
data from database how to select
data from database using Dao in struts
Hi,
You have to load the
data from database using hibernate and send the
data in a Java file object to jsp page.ADS_TO_REPLACE_1
retrive data from database retrive
data from database hi..
i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in
database access sheet i want to view it at any another
To retrive data from database - StrutsTo retrive
data from database How to get values ,when i select a select box in jsp and has to get values in
textbox automatically
from database?
eg... come to jsp page automatically
from database retrieve data from database using jsf retrieve
data from database using jsf Hello
I want an example of source code to retrieve
data from database
i have a
database (oracle) name as db1...),, name ,and city
I want after enter value in
textbox according idauthor i retrieve
delete data from database - SQLdelete
data from database HOw to delete specific
data from table>
I want to delete one record
from database.
Thnx Hi friend,
--------------------------------------------
Visit for more information
Problem in accessing data from DatabaseProblem in accessing
data from Database hi.....
i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my
database is text and all others are of currency
data type. If i enter 0 or null value
retrieve data from database with hyperlinkretrieve
data from database with hyperlink sir....i have one table called 'name' having two values i have to retrieve those
data with a hyperlink and show in browser and if we click hyperlink its shows his sub categories....how
retrieve data from mysql databaseretrieve
data from mysql database hi am not familiar in php.....even... selected value on combobox which is to be retrieve the relevant
data from mysql
database using php.... below my code is that..
<html>
<head>
retreive integer data from databaseretreive integer
data from database i made a table named result...=lalit&
database=mydb");
String url="select marks
from student where rollno... and two buttons "ok" and "cancel" i want to take input
from textfield
Data retrieve from mysql databaseData retrieve
from mysql database Hi sir,
please give some example of jsp code for retrieving mysql
database values in multiple dropdown list...
from the dropdown, related
data will get displayed on the textboxes. Here we have
Why you are not getting value from your data science?Why you are not
getting value
from your
data science? Hi,
I am... for
the tutorials to learn:
Why you are not
getting value
from your
data science?
Try...;Why you are not
getting value
from your
data science?". Also tell me which
GWT -- retrive the data from DatabaseGWT -- retrive the
data from Database the user can create an event. In the create page, we have three buttons. Save as draft, preview and save... button, you have to create a dynamic jsp which should read the contents
from Retrieve data from the database and write into ppt fileJava Retrieve
data from the
database & write into ppt file
In this section, we are going to retrieve
data from the
database and write into the .ppt file... *
from data");
String name = "";
String address = "";
while (rs.next