Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JSP文件在Eclipse中工作正常,但在Tomcat/webapps中工作不正常_Java_Javascript_Jsp_Tomcat - Fatal编程技术网

Java JSP文件在Eclipse中工作正常,但在Tomcat/webapps中工作不正常

Java JSP文件在Eclipse中工作正常,但在Tomcat/webapps中工作不正常,java,javascript,jsp,tomcat,Java,Javascript,Jsp,Tomcat,我有一个page.jsp,它有三个字段:old、new和confirm password。我有一个JavaScript来检查确认密码和新密码是否相同。当我在Eclipse中测试它时,它是按照要求工作的,所以我在Tomcat/webapps中部署了它。但当我运行它时,它不会检查新密码和确认密码字段 请告诉我怎么做 我的web应用程序的屏幕截图: 源代码: <%@ page language="java" contentType="text/html; charset=ISO-8859-1"

我有一个page.jsp,它有三个字段:old、new和confirm password。我有一个JavaScript来检查确认密码和新密码是否相同。当我在Eclipse中测试它时,它是按照要求工作的,所以我在Tomcat/webapps中部署了它。但当我运行它时,它不会检查新密码和确认密码字段

请告诉我怎么做


我的web应用程序的屏幕截图:

源代码:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
html, body, div, h1, h2, h3, h4, h5, h6, p, img, dl,
  dt, dd, ol, ul, li, table, tr, td, form, object, embed,
  article, aside, command, details, fieldset,
  figcaption, figure, footer, group, header, hgroup, legend
 {
  margin: 0;
  padding: 0;
  border: 0;
  }
html {
  font: 82.5% verdana, helvetica, sans-serif;
  background: #fff;
  color: #333;
  line-height: 1;
  direction: ltr;
  }
  html, body {
  position: absolute;
  height: 100%;
  min-width: 100%;
  } 

  table {
  border-collapse: collapse;
  border-spacing: 0;
  }



  .button {
  min-width: 46px;
  text-align: center;
  color: #444;
  font-size: 11px;
  font-weight: bold;
  height: 27px;
  padding: 0 8px;
  line-height: 27px;
  border-radius: 2px;
  transition: all 0.218s;
  border: 1px solid #dcdcdc;
  background-color: #f5f5f5;
  cursor: default;
  }

  *+html .button {
  min-width: 70px;
  }
  button.button,
  input[type=submit].button {
  height: f1f1f1px;
  line-height: 29px;
  vertical-align: bottom;
  margin: 0;
  }

  .button:hover {
  border: 1px solid #c6c6c6;
  color: #333;
  text-decoration: none;
  transition: all 0.0s;
  background-color: #f8f8f8;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
  }
  .button:active {
  background-color: #f6f6f6;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  }
  .button:visited {
  color: #666;
  }  
   .button-submit {
  border: 1px solid #3079ed;
  color: #fff;
  text-shadow: 0 1px rgba(0,0,0,0.1);
  background-color: #4d90fe;
  }
  .button-submit:hover {
  border: 1px solid #2f5bb7;
  color: #fff;
  text-shadow: 0 1px rgba(0,0,0,0.3);
  background-color: #357ae8;
  }
  button-submit:active {
  background-color: #357ae8;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  }

  .footer-bar {
  bottom: 0;
  height: 35px;
  width: 100%;
  overflow: hidden;
  }
  .content {
  padding: 0 44px;
  }

  .table{
    padding: 0 55px
  }
.header
  {
  padding: 10px 20px 5px;
  background:#00AAFF;
  border: 1px solid #e5e5e5;
  height:20px;
  }
</style>
<script type="text/javascript">
function ccheck()
{

newPsw=document.f1.newPsw.value;

old=document.f1.old.value;
confirm=document.f1.confirm.value;

if(old=="" || old==null)
{
alert("Plz. Enter Your old password");
document.f1.old.focus();
return false;
}
if(confirm=="" || confirm==null)
{
alert("Plz. Enter Your confirm Password");
document.f1.confirm.focus();
return false;
}
i
if(newPsw=="" || newPsw==null )
{
alert("Plz. Enter Your new password");
document.f1.newPsw.focus();
return false;

}
if(newPsw!=confirm)
    {
    alert("new password and confirm does not match");
    document.f1.newPsw.focus();
    return false;

    }

return true;
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="">
<form name="f1" id="f1" action="checkPassword.jsp" onsubmit="return ccheck()">
        <div align="center" style="padding-top: 30px">
            <table  cellspacing="10" cellpadding="10">
                <tr>
                    <td width="200" height="30"><h5>Old Password</h5></td>
                    <td  height="30"><input name="old" type="password"></td>
                </tr>
                <tr>
                    <td  height="30"><h5>New Password</h5></td>
                    <td  height="30"><input name="newPsw" type="password"></td>
                </tr>
                <tr>
                    <td height="30"><h5>Confirm Password</h5></td>
                    <td  height="30"><input name="confirm" type="password"></td>
                </tr>
            </table>
        </div>
        <div class="footer-bar"  align="center" style="padding-top: 30px">
            <table align="center" >
                <tr >
                    <td width="100" align="center"><input type="submit" class="button button-submit" value="Submit"  /></td>
                    <td width="100" align="center"><input type="reset" class="button button-submit" value="Reset" /></td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

html、正文、div、h1、h2、h3、h4、h5、h6、p、img、dl、,
dt、dd、ol、ul、li、表格、tr、td、表格、对象、嵌入、,
文章、旁白、命令、细节、字段集、,
figcaption、图、页脚、组、页眉、组、图例
{
保证金:0;
填充:0;
边界:0;
}
html{
字体:82.5%verdana,helvetica,无衬线;
背景:#fff;
颜色:#333;
线高:1;
方向:ltr;
}
html,正文{
位置:绝对位置;
身高:100%;
最小宽度:100%;
} 
桌子{
边界塌陷:塌陷;
边界间距:0;
}
.按钮{
最小宽度:46px;
文本对齐:居中;
颜色:#444;
字体大小:11px;
字体大小:粗体;
高度:27px;
填充:0 8px;
线高:27px;
边界半径:2px;
过渡:均为0.218s;
边框:1px实心#DCDC;
背景色:#F5;
游标:默认值;
}
*+按钮{
最小宽度:70px;
}
按钮,按钮,
输入[type=submit]。按钮{
高度:f1px;
线高:29px;
垂直对齐:底部对齐;
保证金:0;
}
.按钮:悬停{
边框:1px实心#C6;
颜色:#333;
文字装饰:无;
转换:所有0.0;
背景色:#F8;
盒影:0 1px 1px rgba(0,0,0,0.1);
}
.按钮:激活{
背景色:#f6f6f6;
盒影:插入0 1px2pRGBA(0,0,0,0.1);
}
.按钮:已访问{
颜色:#666;
}  
.按钮提交{
边框:1px实心#3079ed;
颜色:#fff;
文本阴影:0 1px rgba(0,0,0,0.1);
背景色:#4d90fe;
}
.按钮提交:悬停{
边框:1px实心#2f5bb7;
颜色:#fff;
文本阴影:0 1px rgba(0,0,0,0.3);
背景色:357ae8;
}
按钮提交:活动{
背景色:357ae8;
盒影:插入0 1px2pRGBA(0,0,0,0.3);
}
.页脚栏{
底部:0;
高度:35px;
宽度:100%;
溢出:隐藏;
}
.内容{
填充:0 44px;
}
.桌子{
填充:0 55px
}
.标题
{
填充:10px 20px 5px;
背景:#00AAFF;
边框:1px实心#e5;
高度:20px;
}
函数ccheck()
{
newPsw=document.f1.newPsw.value;
old=document.f1.old.value;
确认=document.f1.confirm.value;
if(old==“”| old==null)
{
警报(“请输入您的旧密码”);
document.f1.old.focus();
返回false;
}
如果(确认==“”|确认==空)
{
警报(“请输入您的确认密码”);
document.f1.confirm.focus();
返回false;
}
我
if(newPsw==“”| | newPsw==null)
{
警报(“请输入新密码”);
document.f1.newPsw.focus();
返回false;
}
如果(newPsw!=确认)
{
警报(“新密码与确认不匹配”);
document.f1.newPsw.focus();
返回false;
}
返回true;
}
旧密码
新密码
确认密码

在你的问题中,我明白了

if(confirm=="" || confirm==null)
{
  alert("Plz. Enter Your confirm Password");
  document.f1.confirm.focus();
  return false;
}
i
if(newPsw=="" || newPsw==null )
{
额外的
i
是一个问题,可能导致jsp失败。我只是不明白为什么它会在eclipse中工作


旁注:在你完成这项工作后,最好将样式部分分解成一个.css文件。

你检查过浏览器中的javascript控制台是否有任何错误吗?@NilsH抱歉,我是javascript新手,我不知道如何做。请告诉我请删除所有无用的代码(如不相关的css)。问题应仅包含诊断/测试所需的最低要求。关于JavaScript控制台,这是Web Dev 101——请做一些研究。您指的是哪个额外的I?在第7行引号中,在两个if语句之间。第5行引号中表示
return false
。第六条引用的线是一个紧密的大括号。引用的第7行是字母
i
本身。第8行引号是
if(newPsw==“”| | newPsw==null)
为这个愚蠢的错误感到抱歉。我真的很感谢你。谢谢。我有一个登录页面,它将在那里检查用户名和密码,并将移到frameset.jsp。我已经包括了navbar.jsp和home.jsp。在home.jsp中,我有password.jsp。因此,当我运行localhost:8080/test/Password.jsp时,它会以javascript的正常功能运行,比如检查空字段。但当我在登录后运行localhost:8080/test时,它将移动到home.jsp,之后当我单击ChangePassword时,它不会检查空字段。我希望你能理解我的问题