excusez moi voici la derniere version:
<%@ page language="java" import="java.sql.*" %>
<%!

// presentation
final String styleTableBeg = "<TABLE>";
final String styleTableEnd = "</TABLE>";
final String styleDataRowBeg = "<TR>";
final String styleDataRowEnd = "</TR>";
final String styleHeaderCellBeg = "<TH>";
final String styleHeaderCellEnd = "</TH>";
final String styleStringCellBeg = "<TD>";
final String styleStringCellEnd = "</TD>";

// database connection
final String drv = "sun.jdbc.odbc.JdbcOdbcDriver";
final String url = "jdbc:odbc:mabase";
final String login = "";
final String psw = "";

// Encodage HTML
String HTMLEncode( String str ) {
        String res = "";

        if( str == null ) return res;

        for( int i = 0; i < str.length(); i++ ) {
                char c = str.charAt( i );
                switch( c ) {
                        case '<' : res += "&lt;"; break;
                        case '>' : res += "&gt;"; break;
                        case '&' : res += "&amp;"; break;
                        default : res += c;
                }
        }

        return res;
}

// Fabrique un �tat sur une table quelconque
void doReport( String query, JspWriter out) {
        Connection con;
        Statement stmt;
        ResultSet rs;
        ResultSetMetaData md;
        int numCols;

        // open driver
        try {
            Class.forName( drv );
        } catch( Exception ex ) {
                System.out.println( "<P>erreur : driver " + drv + " : " + ex
);
                return;
        }

        try {
                con = DriverManager.getConnection( url, login, psw );
                stmt = con.createStatement();
                rs = stmt.executeQuery(query);
                md = rs.getMetaData();
                numCols = md.getColumnCount();

                // print headers
                System.out.println( styleTableBeg );
                System.out.println( styleDataRowBeg );
                for( int i = 1; i <= numCols; i++ ) {
                        System.out.println( styleStringCellBeg );
                        System.out.println( HTMLEncode( md.getColumnName( i
) ) );
                        System.out.println( styleStringCellEnd );
                }
                        System.out.println( styleDataRowEnd );

                // report loop
                while( rs.next() ) {
                        System.out.println( styleDataRowBeg );
                        for( int i = 1; i <= numCols; i++ ) {
                                System.out.println( styleStringCellBeg );
                                System.out.println( HTMLEncode(
rs.getString( i )));
                                System.out.println( styleStringCellEnd );
                        }
                        System.out.println( styleDataRowEnd );
                }

                System.out.println( styleTableEnd );

                stmt.close();
                con.close();
        }
        catch( SQLException ex ) {
            System.out.println( "</table><P>SQLException: " + ex + "</P>" );
        }

}

%>
<html>
<head>
        <title>Mon Premier Etat avec JSP et JDBC</title>
        <link  rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<%
        String strTableName = request.getParameter("TableName");
        if( strTableName != null ) {
%>
                <H1>Liste des enregistrements de <%=HTMLEncode( strTableName
)%></h1>
                <p>
<%
                doReport( "select * from " + strTableName, out );

%>
                </p>
<%
        }
        else {
%>
                <h1>Etat d'une Table</h1>
                <form action="myfirst.jsp" method="post">
                <p>Nom de la table: <input type="text" name="TableName"></p>
                <p><input type="submit"></p>
                </form>
<%
        }
%>
<hr>
</body>
</html>

-----Message d'origine-----
De : Veronique Dupierris [mailto:[EMAIL PROTECTED]]
Envoy� : mardi 22 ao�t 2000 17:56
� : [EMAIL PROTECTED]
Objet : Re: out.println( styleTableBeg ); not the good syntax ?


In your jsp file you have certainly use a class method which throws a
IOException
and you should catch this exception ... Can't you send
the portion of your code which causes the problem ?! It would be easier to
explain
what's going on ...

Regards
veronique

Erwan TROEL a �crit :

> Does anybody what is my problem? with:
> out.println( styleTableBeg );
> org.apache.jasper.JasperException: Unable to compile class for
>
JSPC:\jakarta-tomcat\work\localhost_8080\_0002fmyfirst_0002ejspmyfirst_jsp_1
> 8.java:80: Exception java.io.IOException must be caught, or it must be
> declared in the throws clause of this method.
>
>
==========================================================================>
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

==========================================================================To
unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to