ho abbozzato una prima "prova" di servlet...
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Login extends HttpServlet
{
//Initialize global variables
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
//Process the HTTP Post request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String USR = request.getParameter("usr");
String PWD = request.getParameter("pws");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection=DriverManager.getConnection("jdbcdbc: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;
}
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("<h1>Sei autenticato...!!!</h1>");
}else{
out.println("<h1>Sei autenticato...!!!</h1>");
}
out.println("</body></html>");
connection.close();
out.close();
}
/* tratto ugualmente i due metodi GET e POST..... */
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
} // end doPost(...)
}
con un bel pò di errori..
C:\java>javac Login.java
Login.java:21: cannot resolve symbol
symbol : class Connection
location: class Login
Connection connection=DriverManager.getConnection("jdbcdbc:login");
^
Login.java:21: cannot resolve symbol
symbol : variable DriverManager
location: class Login
Connection connection=DriverManager.getConnection("jdbcdbc:login");
^
Login.java:22: cannot resolve symbol
symbol : class Statement
location: class Login
Statement statement = connection.createStatement();
^
Login.java:24: cannot resolve symbol
symbol : class ResultSet
location: class Login
ResultSet rs = statement.executeQuery(sql);
^
4 errors
che dite sono poprio sulla strada sbagliata....
Del resto ho preso quello che avevo messo nella jsp e l'ho integrato nella servlet che chiamero chìome diceva Angelo dall'action del form della pagina html.
Spero in vostro aiuto
Giuseppe R.

dbc:login");
Rispondi quotando