站长资源网络编程

关于JSP的一点疑问小结

整理:jimmy2024/10/27浏览2
简介希望谁能帮我看一看问题出在哪?谢谢! register.html部分: 复制代码 代码如下: register.html</titl</div> <div class="news_infos"><div id="MyContent">希望谁能帮我看一看问题出在哪?谢谢! <BR>register.html部分: <BR><U>复制代码</U> 代码如下:<BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <BR><html> <BR><head> <BR><title>register.html</title> <BR><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <BR><meta http-equiv="description" content="this is my page"> <BR><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <BR><!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <BR></head> <BR><body> <BR><br> <BR><form action="register.jsp" method = "Post" name = "frm"> <BR>用户名:<input type = "text" name = "in_username"><br> <BR>密码:<input type = "password" name = "in_password"><br> <BR><input type = "submit" name = "submit" value = "提交"> <BR></form> <BR></body> <BR></html> <BR><BR>register.jsp部分: <BR><U>复制代码</U> 代码如下:<BR><%@ page language="java" import = java.util.* pageEncoding="ISO-8859-1"%> <BR><% <BR>String path = request.getContextPath(); <BR>String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; <BR>%> <BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <BR><html> <BR><head> <BR><base href="<%=basePath%>"> <BR><title>My JSP 'register.jsp' starting page</title> <BR><meta http-equiv="pragma" content="no-cache"> <BR><meta http-equiv="cache-control" content="no-cache"> <BR><meta http-equiv="expires" content="0"> <BR><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <BR><meta http-equiv="description" content="This is my page"> <BR><meta http-equiv = "content-type" content = "text/html;charset = gb2312"> <BR><!-- <BR><link rel="stylesheet" type="text/css" href="styles.css"> <BR>--> <BR></head> <BR><body> <BR><br> <BR><%! boolean isnotlogin = false;%> <BR><% <BR>String username = request.getParameter("username"); <BR>String password = request.getParameter("password"); <BR>if(username == null || password == null) <BR>{ <BR>response.sendRedirect("error.jsp"); <BR>return; <BR>} <BR>%> <BR><jsp:useBean id="person" scope = "page" class = "mypack.register"> <BR><jsp:setProperty name = "person" property = "username" param = "username"/> <BR><jsp:setProperty name = "person" property = "pwd" param = "password"/> <BR></jsp:useBean> <BR><% <BR>isnotlogin = person.judge(); <BR>if(!isnotlogin) <BR>{ <BR>response.sendRedirect("error.jsp"); <BR>return; <BR>} <BR>else <BR>{ <BR>session.setAttribute("username", request.getParameter("username")); <BR>%> <BR><jsp:forward page = "sbmt"> <BR><jsp:param name = "username" value = "<%=username%>"/> <BR></jsp:forward> <BR><% <BR>} <BR>%> <BR></body> <BR></html> <BR><BR>register.java(JavaBean)部分: <BR><U>复制代码</U> 代码如下:<BR>package mypack; <BR>public class register { <BR>private String username = ""; <BR>private String pwd = ""; <BR>public void setUserName(String nm) <BR>{ <BR>this.username = nm; <BR>} <BR>public String getUserName() <BR>{ <BR>return this.username; <BR>} <BR>public void setPwd(String pd) <BR>{ <BR>this.pwd = pd; <BR>} <BR>public String getPwd() <BR>{ <BR>return this.pwd; <BR>} <BR>public boolean judge() <BR>{ <BR>boolean temp = false; <BR>if(username.equals("teacher") && pwd.equals("teacher")) <BR>{ <BR>temp = true; <BR>} <BR>return temp; <BR>} <BR>} <BR>sbmt.java(Servlet)部分: <BR>package mypack; <BR>import java.io.IOException; <BR>import java.io.PrintWriter; <BR>import javax.servlet.ServletException; <BR>import javax.servlet.http.HttpServlet; <BR>import javax.servlet.http.HttpServletRequest; <BR>import javax.servlet.http.HttpServletResponse; <BR>import javax.servlet.http.HttpSession; <BR>public class sbmt extends HttpServlet { <BR>private static final long serialVersionUID = 1L; <BR>public sbmt() { <BR>super(); <BR>} <BR>public void destroy() { <BR>super.destroy(); <BR>} <BR>public void doGet(HttpServletRequest request, HttpServletResponse response) <BR>throws ServletException, IOException { <BR>response.setContentType("text/html"); <BR>PrintWriter out = response.getWriter(); <BR>out <BR>.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); <BR>out.println("<HTML>"); <BR>out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); <BR>out.println(" <BODY>"); <BR>out.print(" This is "); <BR>out.print(this.getClass()); <BR>out.println(", using the GET method"); <BR>out.println(" </BODY>"); <BR>out.println("</HTML>"); <BR>out.flush(); <BR>out.close(); <BR>} <BR>public void doPost(HttpServletRequest request, HttpServletResponse response) <BR>throws ServletException, IOException { <BR>HttpSession session = request.getSession(false); <BR>if(session == null) <BR>{ <BR>response.sendRedirect("error.jsp"); <BR>return; <BR>} <BR>String usernameone = (String)session.getAttribute("username"); <BR>String usernametwo = request.getParameter("username"); <BR>if(!usernameone.equals(usernametwo)) <BR>{ <BR>response.sendRedirect("error.jsp"); <BR>return; <BR>} <BR>response.setContentType("text/html;charset = GBK"); <BR>request.setAttribute("username", usernametwo); <BR>if(usernametwo.equals("teacher")) <BR>{ <BR>response.sendRedirect("teacher.jsp"); <BR>return; <BR>} <BR>else <BR>{ <BR>response.sendRedirect("error.jsp"); <BR>return; <BR>} <BR>} <BR>} <BR>} <BR></div> </div> </div> <div class="share"> </div> <div class="nextinfo"> <p>上一篇:<a href="http://m.wwsws.com/show/1/163235.html" title="JSP 多条SQL语句同时执行的方法">JSP 多条SQL语句同时执行的方法</a></p> <p>下一篇:<a href="http://m.wwsws.com/show/1/163237.html" title="IE cache缓存 所带来的问题收藏">IE cache缓存 所带来的问题收藏</a></p> </div> <div class="otherlink"> <h2>最新资源</h2> <ul> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620773.html" one-link-mark="yes" title="群星《歌手2024 第3期》[FLAC/分轨][204.16MB]"><span>群星《歌手2024 第3期》[FLAC/分轨][204.16MB]</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620772.html" one-link-mark="yes" title="群星《乘风2024 第6期》[320K/MP3][57.95MB]"><span>群星《乘风2024 第6期》[320K/MP3][57.95MB]</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620771.html" one-link-mark="yes" title="群星《乘风2024 第6期》[FLAC/分轨][170.72MB]"><span>群星《乘风2024 第6期》[FLAC/分轨][170.72MB]</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620770.html" one-link-mark="yes" title="陈立强1995-我爱你胜过这世界[福茂][WAV+CUE]"><span>陈立强1995-我爱你胜过这世界[福茂][WAV+CUE]</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620769.html" one-link-mark="yes" title="群星-《2014年十大发烧唱片精选HQCD》[低速原抓WAV+CUE]"><span>群星-《2014年十大发烧唱片精选HQCD》[低速原抓</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620768.html" one-link-mark="yes" title="群星2013-青春缤纷辑压箱宝大公开3CD2[新加坡限量版][WAV整轨]"><span>群星2013-青春缤纷辑压箱宝大公开3CD2[新加坡限</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620767.html" one-link-mark="yes" title="林育群.2013-BalladShow(日本版)【环球】【WAV+CUE】"><span>林育群.2013-BalladShow(日本版)【环球】【WAV+</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620766.html" one-link-mark="yes" title="陈加洛.1992-痛到感觉不到【宝丽金】【WAV+CUE】"><span>陈加洛.1992-痛到感觉不到【宝丽金】【WAV+CUE】</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620765.html" one-link-mark="yes" title="群星.2023-宿命之敌电视剧原声带【韶愔音乐】【FLAC分轨】"><span>群星.2023-宿命之敌电视剧原声带【韶愔音乐】【</span></a> </li> <li> <i class="iconfont icon-point"></i> <a class="text-sm" href="/show/1/620764.html" one-link-mark="yes" title="東京事変-大発見[FLAC+CUE]"><span>東京事変-大発見[FLAC+CUE]</span></a> </li> </ul> </div> </div> <div class="sidebar"> <div class="cloud"><h2 class="hometitle">一句话新闻</h2><a href="/3G/1/604690.html"><ul>Windows上运行安卓你用过了吗<br><br>在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。</ul></a></div> </div> </article> <footer> <p>友情链接:<a href="http://www.imxmx.com/" title="杰晶网络" target="_blank">杰晶网络</a> <a href="http://www.ddrfans.com/" title="DDR爱好者之家" target="_blank">DDR爱好者之家</a> <a href="http://www.nqxw.com/" title="南强小屋" target="_blank">南强小屋</a> <a href="http://www.paidiu.com/" title="黑松山资源网" target="_blank">黑松山资源网</a> <a href="http://www.dyhadc.com/" title="白云城资源网" target="_blank">白云城资源网</a> <a href="/sitemap.xml">SiteMap</a></p> <p>Design by <a href="http://m.wwsws.com">伏龙阁资源网</a> <a href="/">http://m.wwsws.com</a></p> </footer> <script src="/images/nav.js"></script> <script type="text/javascript"> jQuery.noConflict(); jQuery(function() { var elm = jQuery('#left_flow2'); var startPos = jQuery(elm).offset().top; jQuery.event.add(window, "scroll", function() { var p = jQuery(window).scrollTop(); jQuery(elm).css('position', ((p) > startPos) ? 'fixed' : ''); jQuery(elm).css('top', ((p) > startPos) ? '0' : ''); }); }); </script> </body> </html>