JBTALKS.CC

标题: JSP + Servlet [打印本页]

作者: 希涯    时间: 2011-12-14 04:36 PM
标题: JSP + Servlet
小弟新手 刚学JSP  问题多多

这是我的部分的JSP
  1. <body>
  2.         <img src="../image/user_student.png" cellspacing="0" cellpadding="0" valign="bottom"></img><span class="titletext">  Student Control Page Login</span>
  3.         <hr />
  4.         </br>
  5.         <form enctype="multipart/form-data" method="POST" onSubmit="return submitForm();" name=frm>
  6.         <label>Student ID :</label> <br/>
  7.         <input name="stuID" id="stuID" type="text" autofocus/><br><br/>
  8.         
  9.         <label>Password :</label> <br/>
  10.         <input name="stuPW" id="stuPW" type="password"/><br><br/>
  11.         
  12.         <div class="password"><a href="forgotPasswordMain.jsp">Forgot your password?</a></div></br>
  13.         <input class="" type="submit" value="Submit" name="Submit" id="submit" onclick="doSubmit()" />
  14.         
  15.         <INPUT type=hidden name="hdLogin" value=""/>
  16.         </form>        
  17.     </body>
复制代码
我是用 Javascript 来 call Servlet
  1.   function doSubmit(){
  2.                 var f = document.frm;
  3.                 f.hdLogin.value = f.stuID.value+";"+f.stuPW.value;
  4.                 f.method = "POST";
  5.                 f.target = "_self";
  6.                 f.action = "servLogin";
  7.                 f.submit();
  8.             }
  9.         </script>
复制代码
Servlet的 class file 就放在跟JSP同一个directory

用尽了很多方法还是解决的不了

当我按submit :

HTTP Status 404 - /StuAttMgmtSys/main/servLogin

type Status report

message /StuAttMgmtSys/main/servLogin

description The requested resource (/StuAttMgmtSys/main/servLogin) is not available.

Apache Tomcat/7.0.14

到底是什么出了问题 帮帮忙   谢谢
作者: 宅男-兜着走    时间: 2011-12-14 08:57 PM
404 Not found 吗?  

你手动key url http://localhost/StuAttMgmtSys/main/servLogin.jsp
试试看有没有呗, 没有的话就找到有为止。

然后就修改你的 路径咯。

为什么要 js submit? 可以的话就尽量不要啦。
现在都不懂是你的 路径错, 还是你的 js 带你去荷兰。
作者: 希涯    时间: 2011-12-14 10:48 PM
其实servLogin是java file 来的

f.action = "servLogin"; << 这是拿来call servlet的 class file

除了用 js 来 submit

<form enctype="multipart/form-data" action= “servLogin” method="POST" onSubmit="return submitForm();" name=frm>

以上的方法我也试过了 还是一样  404 Not found 。
作者: 宅男-兜着走    时间: 2011-12-14 11:24 PM
回复 3# 希涯


    你的structure 是如何?
    怎样个直接call class file 法? 如果可以直接 执行 class 不必 initialize 的话, 做得到的话很好
    而且为什么没file extension.
作者: Super-Tomato    时间: 2011-12-15 01:22 AM
小弟新手 刚学JSP  问题多多  

这是我的部分的JSP我是用 Javascript 来 call ServletServlet的 ...
希涯 发表于 2011-12-14 04:36 PM



web.xml 中的 servlet 設定都没錯誤?




欢迎光临 JBTALKS.CC (https://jbtalks.my/) Powered by Discuz! X2.5