NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
madafak14
Joined: 10 Sep 2009 Posts: 5
|
Posted: Mon Sep 14, 2009 4:15 pm Post subject: Problem with jsp:forward |
|
|
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<sql:query var="userPassRs" dataSource="jdbc/RETROSPEKTIVA">
SELECT * FROM Korisnik
WHERE KorisnickoIme = '<%= request.getParameter("KorisnickoIme") %>'
AND Lozinka = '<%= request.getParameter("Lozinka") %>'
</sql:query>
<c:set var="userPass" scope="request" value="${userPassRs.rows[0]}"/>
<jsp:useBean id="validUser" scope="session" class="retrospektiva.Korisnik"/>
<jsp:setProperty name="validUser" property="username" value="${userPass.KorisnickoIme}" />
<jsp:setProperty name="validUser" property="password" value="${userPass.Lozinka}" />
<jsp:setProperty name="validUser" property="name" value="${userPass.ImeKorisnika}" />
<jsp:setProperty name="validUser" property="lastName" value="${userPass.PrezimeKorisnika}" />
<jsp:setProperty name="validUser" property="userType" value="${userPass.TipKorisnika}" />
<html>
<head><title>idemo</title></head>
<body>
<%
String usrtype = validUser.getUserType();
if (usrtype == "admin")
{
%>
<jsp:forward page = "jsp/administrator.jsp"/>
<%
}
else if (usrtype == "prof")
{
%>
<jsp:forward page = "profesor.jsp"/>
<%
}
else if (usrtype == "stud")
{
%>
<jsp:forward page = "student.jsp"/>
<%
}
else
{
out.println("Login failed");
}
%>
</body>
</html>
Here is the code for my authenticate.jsp page. I keep getting "Login failed" message. Does anyone know where the mistake is? |
|
| Back to top |
|
 |
Bman
Joined: 16 Sep 2009 Posts: 1
|
Posted: Wed Sep 16, 2009 10:50 pm Post subject: |
|
|
Change the way you compare strings in these 3 lines:
| Code: | if (usrtype == "admin")
else if (usrtype == "prof")
else if (usrtype == "stud") |
using the compareTo() method which returns 0 when string objects are equal, so it looks like:
| Code: | if (usrtype.compareTo("admin") == 0)
else if (usrtype.compareTo("prof") == 0)
else if (usrtype.compareTo("stud") == 0) |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|