JSP(JavaServer Pages)是一种用于创建动态Web内容的技术,它允许开发者在HTML页面中嵌入Java代码。以下是一个简单的JSP登录界面的源代码示例:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login Page</title>
</head>
<body>
<h2>Login</h2>
<form action="loginProcess.jsp" method="post">
Username: <input type="text" name="username"><br><br>
Password: <input type="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
loginProcess.jsp
)<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
if ("admin".equals(username) && "password".equals(password)) {
session.setAttribute("username", username);
response.sendRedirect("welcome.jsp");
} else {
response.sendRedirect("login.jsp?error=1");
}
%>
希望这些信息对你有所帮助。如果你有更多具体的问题或需要进一步的指导,请随时提问。
领取专属 10元无门槛券
手把手带您无忧上云