MrEasy
21.07.2002, 15:28
hab grade mal geschaut, was ich lokal hier an jsp seiten noch rumliegen habe, da hab ich ne simple passwortabfrage gefunden, vielleicht nicht schlecht als kleines beispiel, natürlich isses nicht wirklich toll
wer das ganze in aktion sehen will, kann auf http://www.mycgiserver.com/~mreasy/ schauen
hier der code:
<%
final String PASSWORD = "password";
if (request.getParameter("password") != null && request.getParameter("password").equals(PASSWORD)) {
%>
<html>
<head>
<title>
Startseite
</title>
</head>
<body>
success
</body>
</html>
<%
} //if
else { // nicht eingeloggt
%>
<html>
<body>
<head>
<title>
Startseite
</title>
</head>
<%
// wrong password
if (request.getParameter("login_sent") != null && request.getParameter("login_sent").equals("yes")) {
%>
<p>
nice try buddy, try again
</p>
<%
}
%>
<form name="form1" method="post">
<table align="center">
<tr>
<td>
User
</td>
<td>
<input type="text" name="user">
</td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input type="password" name="password">
<input type="hidden" name="login_sent">
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" value="Login" onclick="javascript:this.document.form1.login_sent.value='yes'; this.document.form1.submit();">
</td>
</tr>
</table>
</form>
</body>
</html>
<%
} //else
%>
wer das ganze in aktion sehen will, kann auf http://www.mycgiserver.com/~mreasy/ schauen
hier der code:
<%
final String PASSWORD = "password";
if (request.getParameter("password") != null && request.getParameter("password").equals(PASSWORD)) {
%>
<html>
<head>
<title>
Startseite
</title>
</head>
<body>
success
</body>
</html>
<%
} //if
else { // nicht eingeloggt
%>
<html>
<body>
<head>
<title>
Startseite
</title>
</head>
<%
// wrong password
if (request.getParameter("login_sent") != null && request.getParameter("login_sent").equals("yes")) {
%>
<p>
nice try buddy, try again
</p>
<%
}
%>
<form name="form1" method="post">
<table align="center">
<tr>
<td>
User
</td>
<td>
<input type="text" name="user">
</td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input type="password" name="password">
<input type="hidden" name="login_sent">
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" value="Login" onclick="javascript:this.document.form1.login_sent.value='yes'; this.document.form1.submit();">
</td>
</tr>
</table>
</form>
</body>
</html>
<%
} //else
%>