ciao a tutti!ho una pagina (index.html)con 2 text,e una pagina login.jsp che verifica che i valori delle text siano presenti in un db e se lo sono apre una session e mi apre la pagina ricerca.jsp. il problema è che anche se inserisco il giusto user mi riporta a index.html e mai in ricerca.jsp
ekko il codice delle 2 pagine:
index.html:
login.jsp:codice:<html> <head> <title>index.html</title> <script type="text/javascript"> function Controllo() { var c = new RegExp ("[^a-z]"); var control = /^[0-9]+$/; if ((document.getElementById("user").value == "") || (document.getElementById("pass").value == "")) { alert("Riempi tutti i campi"); return; } if (c.test(document.getElementById("user").value)) { alert("Non sono ammessi numeri nel campo username"); return; } if ((control.test(document.getElementById("pass").value))){ alert("La password non deve contenere solo numeri"); return; } else { location.href=("login.jsp"); } } function Reg(){ location.href=("Registrazione.jsp"); } </script> </head> <body> <form name="frmLogin" method="post" action="login.jsp"> <h2 align="center">HOME PAGE</h2> <div align="center"> <table width="308" height="123"> <tr> <td> Username: </td> <td> </td> <td> <input text name="uid" property="" id="user" size="20" tabindex=1/> </td> </tr> <tr> <td> Password: </td> <td> </td> <td> <input type="password" name="pwd" property="" id="pass" size="20" tabindex=2 /> </td> </tr> <tr> <td> <p align="center"> <input type=submit value="Login" tabindex=3 onclick="Controllo()"/> </td> <td> </td> <td> <input type=button value="Registrami" tabindex=4 onclick="Reg()"/> </td> </tr> </table></div> </form> </body></html>
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page language="java" import="java.util.*" import="java.sql.*"%> <html> <head> <title>'login.jsp'</title> </head> <body> <% String strUser = request.getParameter("uid"); String strSQL="SELECT id, user FROM UTENTI"; String strDriver="sun.jdbc.odbc.JdbcOdbcDriver"; String strNomeConnessione="jdbc:odbc:database"; Class.forName(strDriver); Connection conn=null; conn=DriverManager.getConnection(strNomeConnessione); Statement stmDb=conn.createStatement(); ResultSet rsRisultato=null; rsRisultato=stmDb.executeQuery(strSQL); while(rsRisultato.next()){ if(strUser == rsRisultato.getString("user")){ String nome = request.getParameter("uid"); session.setAttribute("uid", nome); Hashtable prod = new Hashtable(); session.setAttribute("Prodotto", prod); %> <jsp:forward page="ricerca.jsp"></jsp:forward> <% } else{ %> <jsp:forward page="index.html"></jsp:forward> <% } }%> </body></html>

Rispondi quotando
