
已解决问题
谷歌poe5用户在2014.09.09提交了关于“罗京J**a中的servlet得不到JSP的值”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-12-27T04:22:48。servlet的程序:packagecom.yuan.servlet;
importj**a.io.IOException;
importcom.yuan.oa.*;
importj**ax.servlet.ServletException;
importj**ax.servlet.http.h**ttpServlet;
importj**ax.servlet.http.h**ttpServletRequest;
importj**ax.servlet.http.h**ttpServletResponse;
publicclassStudentDemoextendsh**ttpServlet{
publicStudentDemo(){
super();
}
publicvoiddestroy(){
super.destroy();//Justputs"destroy"stringinlog
//Putyourcodehere
}
publicvoiddoGet(h**ttpServletRequestrequest,h**ttpServletResponseresponse)
throwsServletException,IOException{
response.setContentType("text/html;charset=gb2312");
StringstuID=request.getParameter("stuID");
StringstuPassword=request.getParameter("stuPassword");
Validateval=newValidate();
if(((stuID!=**ll)&&(stuPassword!=**ll))&&("".equals(stuID)&&"".equals(stuPassword))){
if(val.loginValidate(stuID,stuPassword))
request.getRequestDispatcher("/success.jsp").forward(request,response);
else
request.getRequestDispatcher("/fail.jsp").forward(request,response);
}
else
request.getRequestDispatcher("/login.jsp").forward(request,response);
}
publicvoiddoPost(h**ttpServletRequestrequest,h**ttpServletResponseresponse)
throwsServletException,IOException{
this.doGet(request,response);
}
publicvoidinit()throwsServletException{
}
}
JSP的程序:
<%@pagelanguage="j**a"import="j**a.util.*"pageEncoding="gbk"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPEh**TMLPUBLIC"-//W3C//DTDh**TML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>学生登录界面</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="Thisismypage">
<!--
<linkrel="stylesheet"type="text/css"href="styles.css">
-->
</head>
<body>
<formaction="StudentDemo"name="form1"method="get">
<tablealign="center"bgcolor="#c0fef8">
<caption>学生登陆界面</caption>
<tr>
<td>学号:</td>
<td>
<inputtype=textname="stuID">
</td>
</tr>
<tr>
<td>密码:</td>
<td>
<inputtype=passwordname="stuPassword">
</td>
</tr>
<tr>
<tdcolspan=2>
<inputtype=submitvalue="登录"name="submit">
<inputtype="Reset"value="重置"name="reset">
</td>
</tr>
</table>
</form>
</body>
</html>
为什么,我老是跳到login.jsp!!!就是跳不到success.jsp中去呢???(学号和密码都是正确的,**库连接也没有问题,validate类也可以通过)希望大家能够帮助她。
详细问题描述及疑问:servlet的程序:
packagecom.yuan.servlet;
importj**a.io.IOException;
importcom.yuan.oa.*;
importj**ax.servlet.ServletException;
importj**ax.servlet.http.h**ttpServlet;
importj**ax.servlet.http.h**ttpServletRequest;
importj**ax.servlet.http.h**ttpServletResponse;
publicclassStudentDemoextendsh**ttpServlet{
publicStudentDemo(){
super();
}
publicvoiddestroy(){
super.destroy();//Justputs"destroy"stringinlog
//Putyourcodehere
}
publicvoiddoGet(h**ttpServletRequestrequest,h**ttpServletResponseresponse)
throwsServletException,IOException{
response.setContentType("text/html;charset=gb2312");
StringstuID=request.getParameter("stuID");
StringstuPassword=request.getParameter("stuPassword");
Validateval=newValidate();
if(((stuID!=**ll)&&(stuPassword!=**ll))&&("".equals(stuID)&&"".equals(stuPassword))){
if(val.loginValidate(stuID,stuPassword))
request.getRequestDispatcher("/success.jsp").forward(request,response);
else
request.getRequestDispatcher("/fail.jsp").forward(request,response);
}
else
request.getRequestDispatcher("/login.jsp").forward(request,response);
}
publicvoiddoPost(h**ttpServletRequestrequest,h**ttpServletResponseresponse)
throwsServletException,IOException{
this.doGet(request,response);
}
publicvoidinit()throwsServletException{
}
}
JSP的程序:
<%@pagelanguage="j**a"import="j**a.util.*"pageEncoding="gbk"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPEh**TMLPUBLIC"-//W3C//DTDh**TML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>学生登录界面</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="Thisismypage">
<!--
<linkrel="stylesheet"type="text/css"href="styles.css">
-->
</head>
<body>
<formaction="StudentDemo"name="form1"method="get">
<tablealign="center"bgcolor="#c0fef8">
<caption>学生登陆界面</caption>
<tr>
<td>学号:</td>
<td>
<inputtype=textname="stuID">
</td>
</tr>
<tr>
<td>密码:</td>
<td>
<inputtype=passwordname="stuPassword">
</td>
</tr>
<tr>
<tdcolspan=2>
<inputtype=submitvalue="登录"name="submit">
<inputtype="Reset"value="重置"name="reset">
</td>
</tr>
</table>
</form>
</body>
</html>
为什么,我老是跳到login.jsp!!!就是跳不到success.jsp中去呢???(学号和密码都是正确的,**库连接也没有问题,validate类也可以通过)期待您的答案,谢谢你帮我,祝你快乐,愿你事事如意
!