grazie V1RuZ del chiarimento...
allora per il resto io ho provato a fare così...
Codice PHP:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class Login extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
try
{
String USR = request.getParameter("usr");
String PWD = request.getParameter("pws");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection=DriverManager.getConnection("jdbc:odbc:login");
Statement statement = connection.createStatement();
String sql="SELECT * FROM Nominativi where username = '"+USR+"' and password='"+PWD+"'";
ResultSet rs = statement.executeQuery(sql);
boolean abilitato= false;
while(rs.next()){
abilitato = true;
nome = rs.getString(1);
cognome = rs.getString(2);
out.println("Nome "+nome);
out.println("Cognome "+cognome);
}
response.setContentType("text/html");
PrintWriter out = new PrintWriter (response.getOutputStream());
out.println("<html>");
out.println("<head><title>Autenticazione</title></head>");
out.println("<body bgColor=#33CCFF");
if (abilitato)
{
out.println("<HR>
<h1>[B] **** Sei autenticato...!!! **** [/B]</h1>");
}else{
out.println("
<h1>[B] **** NON autenticato...!!! **** [/B]</h1>");
}
out.println("</body></html>");
connection.close();
out.close();
}
catch (SQLException e)
{
}
catch(ClassNotFoundException e)
{
}
catch(Throwable theException)
{
}
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
doGet(request, response);
} // end doPost(...)
}
ma mi da questi errori:
C:\java>javac Login.java
Login.java:32: cannot resolve symbol
symbol : variable nome
location: class Login
nome = rs.getString(1);
^
Login.java:33: cannot resolve symbol
symbol : variable cognome
location: class Login
cognome = rs.getString(2);
^
Login.java:35: cannot resolve symbol
symbol : variable nome
location: class Login
out.println("Nome "+nome);
^
Login.java:35: cannot resolve symbol
symbol : variable out
location: class Login
out.println("Nome "+nome);
^
Login.java:36: cannot resolve symbol
symbol : variable cognome
location: class Login
out.println("Cognome "+cognome);
^
Login.java:36: cannot resolve symbol
symbol : variable out
location: class Login
out.println("Cognome "+cognome);
^
6 errors
mi sapreste dire il perchè??
possibile che non riesca a stampare un recordset??
Ciao a tutti e buona giornata.
Giuseppe