Looks like you're using a declaration instead of a scriptlet. Replace <%! ... %>
with <% ... %>.

Luc Saint-Elie wrote:

> Hello,
>
> Its probably a trivial (stupid ?) question, but I fail.. i'm trying to
> convert a servlet to a JSP page, and I'd like to use DBConnectionPool (i
> use it for servlets and it works well). I'm trying to follow the example
> given in the FAQ and I get the following error :
>
> com.sun.jsp.JspException: Compilation
> failed:work\localhost%3A80%2F\showpart_jsp_1.java:28: Type expected.
>                  if (con == null) {
>                  ^
> 1 error
>
> Any idea ??? the infamous line of code is :
>
> <%!
> String strCATEGORIE = request.getParameter("CATEGORIE");
> Connection con = connMgr.getConnection("idb");
>          if (con == null) {                        ======> PROBLEM ????????
>          out.println("Can't get connection");
>          return;
>
> Here is my whole code :
>
> //----------- START OF CODE ---------
> <%@ page language="java" import="java.sql.*" %>
> <%!
> DBConnectionManager connMgr = DBConnectionManager.getInstance();
> %>
>
> //============ pure HTML part ============
> <html>
> <head>
> <title>Les partenaires enregistres</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <link rel="stylesheet" href="/style.css">
> </head>
> <body bgcolor="#FFFFFF">
> <p align="center">[<a href="../">RETOUR</a>]
> <br>
> voilà ce que nous avons en stock</p>
> <p>Lorsque vous appelez quelqu'un r&eacute;f&eacute;renc&eacute; ici, merci
> de :<br>
> a) l'appeler de <b>ma</b> part
> <br>
> b) Me faire un petit <a
> href="mailto:[EMAIL PROTECTED]">mail</a> pour que je sois au
> courant de ce que l'on fait et avec qui
> <br>
> C) Etre &quot;super professionnel&quot; (m&ecirc;me si votre client lui, ne
> l'est pas vraiment)</p>
>
> <table border="0" class="TBLresultat">
> //============= end of pure HTML part ============
>
> <%!
> String strCATEGORIE = request.getParameter("CATEGORIE");
> Connection con = connMgr.getConnection("idb");
>          if (con == null) {
>          out.println("Can't get connection");
>          return;
>                  }
>          try {
>                  Statement stmt = con.createStatement();
>                  ResultSet rs = stmt.executeQuery ("SELECT * FROM
> PARTENAIRES WHERE CATEGORIE =" +
>
>               strCATEGORIE );
>                 while(rs.next()) {
>                  %>
> <tr>
>          <td width="150">Société </td>
>          <td> <strong><%= rs.getString("SOCIETE") %></strong></td>
> </tr>
> <tr>
>          <td width="150">Notre contact </td>
>          <td> <%=rs.getString("C_PRENOM") %>&nbsp;<%=
> rs.getString("C_NOM")%></td>
> </tr>
> <tr>
>          <td width="150">Il est </td>
>          <td> <%=rs.getString("C_FONCTION") %></td>
> </tr>
> <tr>
>          <td width="150"> son email </td>
>          <td> <a href="mailto:<%=rs.getString("C_EMAIL")
> %>"><%=rs.getString("C_EMAIL") %></a></td>
> </tr>
> <tr>
>          <td width="150"> son téléphone </td>
>          <td> <%=rs.getString("C_PHONE") %> (mobile
> :<%=rs.getString("C_MOBILE") %>)</td>
> </tr>
> <tr>
>          <td width="150"><%= rs.getString("SOCIETE") %> assure les
> prestations suivantes </td>
>          <td><%=rs.getString("PRESTATION") %></td>
> </tr>
> <tr>
>          <td width="150"><strong> Commentaire : </strong></td>
>          <td><%= rs.getString("COMMENT") %></td>
> </tr>
> <tr>
>          <td width="150"><strong> Historique de nos relations </strong></td>
>          <td><%= rs.getString("HISTO") %></td>
> </tr>
> <tr>
>          <td width="150">Le web de <%= rs.getString("SOCIETE") %></td>
>          <td> <a href="<%= rs.getString("WEB") %>"><%= rs.getString("WEB")
> %></a></td>
> <%
>          }
>          stmt.close();
>          rs.close();
>          }
>          catch (SQLException e) {
>                  e.printStackTrace(out);
>                  }
>          connMgr.freeConnection("idb", con);
> %>
> </tr>
> </table><p>
> </body>
> </html>
>
> //----------- END OF CODE ---------
>
> +------------------------------------------------+
> | Luc Saint-Elie                                 |
> | 75018 Paris France                             |
> | Tel: 1(212)894 3713 ext: 0012                  |
> | email : [EMAIL PROTECTED]                    |
> +------------------------------------------------+
> | Java Server Side Open Source technologies      |
> | http://www.interpasnet.com/JSS                 |
> +------------------------------------------------+
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

--
Peace, Anil +<:-)

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to