Case: The username and password information are submitted on the web page, and the backend verification password length must be between 6-12 digits
Backend part
@WebServlet("/valid") public class SimpleServlet extends HttpServlet{ public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException{ // Get the request parameters String username = ("username"); String password = ("password"); // The length of the verification password must be between 6-12 digits String result = "NO"; if (() >= 6 && () <= 12) { result = "YES"; } // Write the result to the response body PrintWriter writer = (); (result); } }
Front-end part
<form action="valid" method="post"> <div> <span>username:</span> <input type="text" name="username"> </div> <div> <span>password:</span> <input type="password" name="password"> </div> <button type="submit">submit</button> </form>
This is the article about using Servlets to write simple interfaces in Javaweb. This is all about this article. For more related content on Javaweb Servlets to write interfaces, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!