hi
i am doing a proj in jsp and oracle 9i. i want to read data from oracle and show it in the text boxes in html/jsp. i know how to read the data from oracle, but i cannot put it into text boxes. can anyone tell me how to do this???

Yes, start off with the excellent J2EE 1.5 tutorials available on java.sun.com which guides you through building a sample web application or get a good J2EE book and start reading.

Member Avatar for electron33

You can create a bean that will hold the data from Oracle. When the page is loading you can fill in the data from database. To do this:
First create a DAO object where the SQL calls to Oracle is called. Add the data to the Bean trough the functions not the constructor. Then create a Servlet to open the JSP page. use request.getRequestDispather to open the JSP page from Servlet. Before the request.getRequestDispather put the bean into request.setAttribute() method. In the JSP you can select if you want to use scripting <% request.getAttribute("test") %> or Taglib i recommends using taglibs (JSTL). Easier to read in jsp pages. Use the <c:out value="${bean.method}"/> to read the values from bean.

I don't know where r u not getting it I have a small scriptlet coding for u

<%
ResultSet rs = st.executeQuery("select count(*) from v$instance ");
while (rs.next())
{
data[0] = rs.getString(1);
}
%>


now in html coding
<input type="text" value="<%= data[1]%>"

hope it work for u

Member Avatar for electron33

I don't recommend putting SQL code inside JSP. It is not a good idea to use scriptlet in JSP. The page code will be hard to maintain. Anyway, If you want to run SQL in JSP. First create a Connection to Oracle.

<%
Connection conn = DriverManager.getConnection("jdbc....", "scott", "tiger");
PrepareStatment stmt = conn.createStatement("select count(*) from tablename");

ResultSet rs = stmt.executeQuery();
String[] data;
while(rs.next()){
  data[0] = String.valueOf( rs.getInt(0) );
}
%>

<input type="text" value="<%= data[0]%>"

The count in SQL returns a integer number

Try this example it should work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.