Home > Back-end >  Why I won't jump duck 0.0 submit the form
Why I won't jump duck 0.0 submit the form

Time:09-29

<% @ page contentType="text/HTML. Charset=utf-8 "language=" Java "% & gt;


Old SAO & lt;/title> <br/><script> <br/>Window. The onl oad=function () {<br/>Document. The getElementById (" img "). The onclick=function () {<br/>This. SRC="https://bbs.csdn.net/day16/checkCodeServlet? Time="+ new Date (). GetTime (); <br/>} <br/>} <br/></script> <br/><style> <br/>Div {<br/>color: red; <br/>} <br/></style> <br/></head> <br/><body> <br/><The from action="/day16/loginServlet" method="post" & gt; <br/><Table> <br/><tr> <br/><td> The user name & lt;/td> <br/><td> <Input type="text" name="username" & gt; </td> <br/></tr> <br/><tr> <br/><td> Password & lt;/td> <br/><td> <Input type="password" name="password" & gt; </td> <br/></tr> <br/><tr> <br/><td> Verification code & lt;/td> <br/><td> <Input type="text" name="checkCode & gt;" </td> <br/></tr> <br/><tr> <br/><Td colspan="2" & gt; <Img id="img" SRC="https://bbs.csdn.net/day16/checkCodeServlet" & gt; </td> <br/></tr> <br/><tr> <br/><Td colspan="2" & gt; <Input type="submit" value="https://bbs.csdn.net/topics/" & gt; </td> <br/></tr> <br/></table> <br/></from> <br/><br/><% -- -- <br/>If incorrect authentication code or the user name password, login. JSP need to decide what is the error and the output message <br/>Here you can use JSP script & lt; %=% & gt; To output tip <br/>- % & gt; <br/><Div> <br/><% -- -- <br/>Judge whether the "login_error" attribute of the Request the domain is empty, don't print it is empty, the same as the following cc_error null will print "" won't show so redundant information <br/>JSP output script can't write the if - else, we can use the ternary operator? Judging: <br/>- % & gt; <br/><%=request. The getAttribute (" login_error ")==null? "" : the request. The getAttribute (" login_error") % & gt; <br/></div> <br/><br/><Div> <br/><%=request. The getAttribute (" cc_error ")==null? "" : the request. The getAttribute (" cc_error") % & gt; <br/></div> <br/><br/></body> <br/></html> <br/><br/><br/><br/><br/><br/><br/>Package cn. Itcast. Servlet. <br/><br/>The import javax.mail. Servlet. ServletException; <br/>The import javax.mail. Servlet. The annotation. WebServlet; <br/>The import javax.mail. Servlet. HTTP. HttpServlet; <br/>The import javax.mail. Servlet. HTTP. It; <br/>The import javax.mail. Servlet. HTTP. HttpServletResponse; <br/>The import javax.mail. Servlet. HTTP. HttpSession; <br/>import java.io.IOException; <br/><br/>@ WebServlet ("/loginServlet ") <br/>Public class LoginServlet extends the HttpServlet {<br/>Protected void doPost (it request, HttpServletResponse response) throws ServletException, IOException {<br/>//1. Set the request code <br/>Request. SetCharacterEncoding (" utf-8 "); <br/>The response. SetContentType (" text/HTML "); <br/>//2. Obtain parameter <br/>String username=request. The getParameter (" username "); <br/>String password=request. The getParameter (" password "); <br/>String checkCode=request. The getParameter (" checkCode "); <br/><br/>//2.1 get first generated captcha <br/>The HttpSession session=request. GetSession (); <br/>String checkCode_session=(String) session. The getAttribute (" checkCode_session "); <br/>Session. RemoveAttribute (" checkCode_session "); <br/><br/>//3. Determine whether captcha first right <br/>If (checkCode_session!=null& & CheckCode_session. EqualsIgnoreCase (checkCode)) {<br/>//ignore case is <br/>//verification code right <br/>//determine whether the user name and password consistent <br/>If (" 123 ". The equals (username) & amp; & "123". The equals (password)) {//call the UserDao query the database <br/>//login success <br/>//storing user information <br/>The session. The setAttribute (" user ", username); <br/>//a redirect to success. The JSP <br/>Response. SendRedirect (request. GetContextPath () + "/success. JSP"); <br/>} else {<br/>//login failed <br/>//store the message to request <br/>Request. SetAttribute (" login_error ", "user name or password error"); <br/>//forwarded to the login page <br/>request.getRequestDispatcher("/login.jsp").forward(request, response); <br/>} <br/>} else {<br/>//inconsistent authentication code <br/>//store the message to request <br/>Request. SetAttribute (" cc_error ", "verification code error"); <br/>//forwarded to the login page <br/>request.getRequestDispatcher("/login.jsp").forward(request, response); <br/>} <br/>} <br/><br/>Protected void doGet (it request, HttpServletResponse response) throws ServletException, IOException {<br/>Enclosing the doPost (request, response); <br/>} <br/>} <br/><p class="article - content rp"> CodePudding user response: </p>See if form form is to see the action or @ webServket path problem (" ")<p class="article - content rp"> CodePudding user response: </p>At the servlet output it and see if invoked the method of the servlet<p class="article - content rp"> CodePudding user response: </p><fieldset> <legend> refer to the second floor JayEOS response: <legend> <blockquote> at the servlet output, look to whether calling the servlet method </blockquote> <fieldset> is no output, but to build a project </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/Backend/40904.html" target="_blank" style="color:#999">https//www.codepudding.com/Backend/40904.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/Backend/40903.html'>Do you have any idea on the solution of the lack of once and for all. Methods on iml file</a></div> <div class="detail-arr-right">Next:<a href='/Backend/40905.html'>The JSP servlet path problem for bosses to solve jump</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=Web+development' target='_blank'>Web development</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>