2016-04-14 53 views
0

jsp.It hoş geldiniz yönlendirmek için home.jsp adlı bir jsp istiyorum çalışmıyor.Please nerede out.I orada düşünmek bana yardımcı below.Please wrong.There üç basit jsp olan gidiyorum söyle veritabanıBen jsp.It karşılama için yönlendirme home.jsp adında bir jsp istiyorum.Lütfen nerede yanlış gidiyorum söyle lütfen

home.jsp- 
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
 
\t pageEncoding="ISO-8859-1"%> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
 
<html> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
 
<title>Welcome</title> 
 
</head> 
 
<body> 
 
<form action='login.jsp' method="post"> 
 
\t <div> 
 
\t \t <table> 
 
\t \t \t <tr> 
 
\t \t \t \t <td>USERNAME</td> 
 
\t \t \t \t <td><input type="text" id="usernameID"/></td> 
 
\t \t \t </tr> 
 
\t \t \t <tr> 
 
\t \t \t \t <td>PASSWORD</td> 
 
\t \t \t \t <td><input type="text" id=passwordID /></td> 
 
\t \t \t </tr> 
 
\t \t \t <tr> 
 
\t \t \t \t <td></td> 
 
\t \t \t \t <td><input type="button" id="loginId" value="LOGIN" /></td> 
 
\t \t \t </tr> 
 
\t \t </table> 
 
\t </div> 
 

 
</form> 
 

 
</body> 
 
</html> 
 
    
 
    
 
    login.jsp- 
 
    <%@ page import="java.sql.*" %> 
 
<%Class.forName("oracle.jdbc.driver.OracleDriver"); %> 
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
 
    pageEncoding="ISO-8859-1"%> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
 
<html> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
 
<title>Insert title here</title> 
 
</head> 
 
<body> 
 
<% 
 
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:8081:XE", "SYSTEM", "Lalita"); 
 

 

 
PreparedStatement ps=(PreparedStatement)con.createStatement(); 
 
String id=request.getParameter("usernameID"); 
 
String password=request.getParameter("passwordID"); 
 
ResultSet rs=ps.executeQuery("select * from USERCREDENTIALS"); 
 
String rsID=rs.getString(1); 
 
String rsPassword=rs.getString(2); 
 
out.println(rsID); 
 
if(id==rsID && password==rsPassword) 
 
\t response.sendRedirect("./welcome.jsp"); 
 

 

 
%> 
 
</body> 
 
</html> 
 
    
 
    
 
    
 
    welcome.jsp- 
 
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
 
    pageEncoding="ISO-8859-1"%> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
 
<html> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
 
<title>Insert title here</title> 
 
</head> 
 
<body> 
 
hiiiiiiiiiiiiiiiiiiiiiiii 
 
</body> 
 
</html>

cevap

0

sen dizinine bağlantılı olarak bazı hatalar olduğunu yönlendirme göndermeye çalışmak yanlış bunu deneyin ...

response.sendRedirect("../welcome.jsp"); 

Çalışması gerekir.

+0

Hala işe yaramadı .... lütfen birilerinin rehberi. Gerçekten nerede yanlış gittiğimi bilmek istiyorum. – Lalita

+0

Oturum açma düğmesine tıkladıktan sonra login.jsp'ye nasıl gidileceğinden sonra sadece form eylemi tarafından yönlendirileceksiniz diye biraz kafam karıştı ??? – Lalita

+0

ho Anladım, giriş tipini ** type = "button" ** 'dan bu ** type = "submit" **' e çevirmeniz gerekiyor. –