Home > Back-end >  Img SRC="a written servlet> authentication code is generated by the servlet written code and
Img SRC="a written servlet> authentication code is generated by the servlet written code and

Time:01-05

Attached source:
O great god
<% @ page pageEncoding="utf-8" % & gt;



<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt;
Registration page & lt;/title> <br/><style type="text/CSS" & gt; <br/>The form {<br/>text-align: center; The internal text center * * let div/<br/>Background - color: RGB (247255243,0.6); <br/>Border - the radius: 20 px; <br/>Width: 320 px; <br/>Height: 250 px; <br/>margin: auto; <br/>Padding: 30 px 1 px 20 px; <br/>top: 0; <br/>left: 0; <br/>right: 0; <br/>bottom: 0; <br/>position: absolute; <br/>} <br/>A {<br/>text-decoration: none; <br/>} <br/>A: hover, a: active {<br/>text-decoration: underline; <br/>} <br/>Body {<br/>Background: url (" https://assets.wallpapersin4k.org/uploads/2017/04/Night-Nature-HD-Wallpapers-17.jpg ") no - repeat center center fixed; <br/>Background - size: 100%; <br/>} <br/><br/></style> <br/></head> <br/><body> <br/><Div & gt; <br/><% <br/>Boolean status=(Boolean) request. GetAttribute (" status "); <br/>String MSG=(String) request. GetAttribute (" MSG "); <br/>If (the status!=null & & Status==Boolean. FALSE) {<br/>Out.println (" & lt; Div style="color: red; The font - size: 0.8 em '& gt;" "+ MSG + & lt;/div>" ); <br/>} <br/>% & gt; <br/><The form action="LogServlet & gt;" <br/><P> Enter account: & lt; Input type="text" name="account" & gt; </p> <br/><P> Enter the password: & lt; Input type="password" name="pass" & gt; </p> <br/><P> Enter the password: & lt; Input type="password" name="pass2 & gt;" </p> <br/><P> Enter the user name: & lt; Input type="text" name="name" & gt; </p> <br/><P> Please enter the verification code: & lt; Input type="text" name="authNum & gt;" </p> <br/><Img SRC="https://bbs.csdn.net/topics/AuthImageServlet" & gt; <br/><A href="https://bbs.csdn.net/topics/index.jsp" & gt; Let me login & lt; existing accounts,/a> & nbsp; & nbsp; <br/><br/><Input type="submit" value="https://bbs.csdn.net/topics/" & gt; <br/></form> <br/></div> <br/></body> <br/></html> <br/><br/>The following is a servlet: <br/>Package com.swu.edu.AuthImage; <br/><br/><br/><br/>The import com. Mysql. Cj. Session; <br/><br/>import javax.imageio.ImageIO; <br/>import javax.servlet.ServletException; <br/>import javax.servlet.annotation.WebServlet; <br/>import javax.servlet.http.HttpServlet; <br/>import javax.servlet.http.HttpServletRequest; <br/>import javax.servlet.http.HttpServletResponse; <br/>The import javax.mail. Servlet. HTTP. HttpSession; <br/>Import the Java. The awt. Color; <br/>Import the Java. The awt. The Font; <br/>Import the Java. The awt. Graphics; <br/>Import the Java. The awt. Image. BufferedImage; <br/>import java.io.IOException; <br/>import java.io.OutputStream; <br/>import java.util.Random; <br/><br/>@ WebServlet ("/AuthImageServlet ") <br/><br/>Public final class AuthImageServlet extends the HttpServlet {<br/>@ Override <br/>Protected void doGet (it the req, HttpServletResponse resp) throws ServletException, IOException {<br/>The doPost (the req, resp); <br/>} <br/><br/>@ Override <br/>Protected void doPost (it the req, HttpServletResponse resp) throws ServletException, IOException {<br/>OutputStream OutputStream=resp. GetOutputStream (); <br/>StringBuilder sb=new StringBuilder();//record output string <br/><br/>BufferedImage image=new BufferedImage (80, 30, BufferedImage. TYPE_INT_RGB); <br/>Graphics graphic=image. GetGraphics (); <br/>Graphic. SetColor (Color getColor (" F8F8F8 "));//fill color <br/>Graphic. FillRect (0, 0, 80, 30);//rectangular render <br/>Color colors=new Color [] [] {<br/>Color BLACK, Color BLUE, Color, GREEN, Color., magenta Color. LIGHT_GRAY <br/>}; <br/>Random random=new Random(); <br/>for (int i=0; i <10; I++) {<br/>Graphic. SetColor (colors [random nextInt (colors. Length)]);//random fill color <br/>Int the x1=random. NextInt (80); <br/>Int y1.=the random nextInt (30); <br/>Int x2=random. NextInt (80); <br/>Int y2=random. NextInt (30); <br/>Graphic. DrawLine (x1, y1, x2, y2); <br/>} <br/>Graphic. The setFont (new Font (" Comic Sans MS ", the Font, BOLD, 30)); <br/>for (int i=0; i <4. I++) {<br/><br/>Int temp=random. NextInt (26) + 97. <br/>String tem=String. The valueOf ((char) temp); <br/>Sb. Append (tem); <br/>Graphic. DrawString (tem, I * 80/4, 25). <br/>} <br/>HttpSession session=req.getSession(); <br/>Session. SetAttribute (" authNum sb. ToString ()); <br/>Graphic. The dispose (); <br/>Try {<br/>ImageIO. Write (image, "jpeg", outputStream); <br/>} the catch (IOException e) {<br/>e.printStackTrace(); <br/>} <br/><br/><br/>} <br/>}<p class="article - content rp"> CodePudding user response: </p><pre> & lt; Img SRC="https://bbs.csdn.net/topics/AuthImageServlet" & gt; </pre> <br/><br/>If you don't have to hide the URL here and modified, that is the wrong, <br/>SRC path may be wrong here, often forget to write down what the project name, press with chrome F12, locating here, and then look at the link is correct </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/Backend/97424.html" target="_blank" style="color:#999">https//www.codepudding.com/Backend/97424.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/Backend/97423.html'>Need the crawler</a></div> <div class="detail-arr-right">Next:<a href='/Backend/97425.html'>How to realize the key combination in Java to monitor events</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>