Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jsp password to link to the next page

Status
Not open for further replies.

ill2000m

Programmer
Mar 25, 2003
2
0
0
GB
I have written a jsp login function which allowed two differnet user to enter different username and password in order to enter the other page. After the user entered the correct username and password, i dont know how to put a link in jsp to let each user link to a different web page, can anyone help???

<%@ page import=&quot;java.util.*&quot;%>

<html>
<head><title>Login</title></head>
<body>

<%!
protected Map users= new HashMap();

public void jspInit(){
//username and password

users.put(&quot;fiona&quot;, &quot;happy&quot;);
users.put(&quot;henry&quot;, &quot;leader&quot;);
}
%>

<%
String username = request.getParameter(&quot;username&quot;);
String password = request.getParameter(&quot;password&quot;);
if (username != null)
username= username.trim();

if(password != null)
password= password.trim();

if (username != null && username.length() >0) {
if (password != null && password.length() >0) {

String pw = (String) users.get(username);

if (pw != null){
if(pw.equals (password)){

String firstname = username;
int i = username.indexOf (' ');

if (i>0)
firstname = username.substring (0, i);

%>

<h1> Login sucessful. </h1>

<%
} else { %>

<h1> Loginfail. Sorry, incorrect password.</h1>

<%
}
} else { %>

<h1>Login fail. Sorry, not a user. </h1>

<%
}
} else { %>
<h1> Loginin fail. Sorry, no password. </h1>

<%
}
} else { %>
<h1> Login fail. Sorry, no username. </h1>

<%
}
%>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top