Consulting data with JSP

Forum sobre a ferramenta Oracle JDeveloper, ADF, OAF, etc. (Não é destinado ao aprendeziado da Linguagem Java em geral)
Post Reply
Chapolim
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 1
Joined: Thu, 01 Dec 2005 10:42 am
Location: POA

Hello,

I am a beginner in jdeveloper and I am trying to create a simple search form in JSP (it has to be in jsp, no uix), with only a textfield field that accesses the database and Returns a person's information.

I created the form in JSP, I created the business objects, I think my problem is in struts, in reality I can not understand how the struts diagram works, there is some specific manual explaining Only the structure of the Struts flow diagram?

How could you make this application work?

S,
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Here are some examples, I think that's what you're looking for: http://docs.oracle.com/cd/A97336_01/bus ... asics7.htm

Select all

<%@ page language="java" import="java.sql.*" %> 
 
<HTML> 
<HEAD> <TITLE> The JDBCQuery JSP  </TITLE> </HEAD> 
<BODY BGCOLOR="white"> 
 
<% String searchCondition = request.getParameter("cond");  
   if (searchCondition != null) { %> 
      <H3> Search results for  <I> <%= searchCondition %> </I> </H3> 
      <B> <%= runQuery(searchCondition) %> </B> <HR><BR> 
<% }  %> 
<B>Enter a search condition:</B> 
<FORM METHOD="get">  
<INPUT TYPE="text" NAME="cond" SIZE=30> 
<INPUT TYPE="submit" VALUE="Ask Oracle"); 
</FORM> 
</BODY> 
</HTML> 
 
<%-- Declare and define the runQuery() method. --%> 
<%! private String runQuery(String cond) throws SQLException { 
     Connection conn = null;  
     Statement stmt = null;  
     ResultSet rset = null;  
     try { 
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); 
        conn = DriverManager.getConnection("jdbc:oracle:oci8:@", 
                                           "scott", "tiger"); 
        stmt = conn.createStatement(); 
        // dynamic query 
        rset = stmt.executeQuery ("SELECT ename, sal FROM scott.emp "+  
                           (cond.equals("") ? "" : "WHERE " + cond )); 
       return (formatResult(rset)); 
     } catch (SQLException e) {  
         return ("<P> SQL error: <PRE> " + e + " </PRE> </P>\n"); 
     } finally { 
         if (rset!= null) rset.close();  
         if (stmt!= null) stmt.close(); 
         if (conn!= null) conn.close(); 
     } 
  } 
  private String formatResult(ResultSet rset) throws SQLException { 
    StringBuffer sb = new StringBuffer(); 
    if (!rset.next()) 
      sb.append("<P> No matching rows.<P>\n"); 
    else {  sb.append("<UL>");  
            do {  sb.append("<LI>" + rset.getString(1) +  
                            " earns $ " + rset.getInt(2) + ".</LI>\n"); 
            } while (rset.next()); 
           sb.append("</UL>");  
    } 
    return sb.toString(); 
  } 
%>
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests