405 POST not supported ???

xxjun 2003-02-19 01:32:43
使用post为什么会出现这样的错误,而使用get则没问题
代码如下,使用resin作服务器
<form action="servlet/login" method="post">public class login extends

login.java
HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try {
......
...全文
199 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
moshco 2003-05-23
  • 打赏
  • 举报
回复
哇!我也是耶!原来解决办法是重启服务!
xxjun 2003-02-21
  • 打赏
  • 举报
回复
这是为什么啊???
xxjun 2003-02-21
  • 打赏
  • 举报
回复
重起机器后,竟然自己好了,!#¥·%!·#*(
xxjun 2003-02-19
  • 打赏
  • 举报
回复
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>login</title>
</HEAD>

<body>
<form action="servlet/login" method="post">

<table>
<tr><td><b>UserName</b>
<td><input type="text" name="username">

<tr><td><b>Password</b>
<td><input type="password" name="password">
</table>

<input type="submit" value="Send">

</form>
</body>
</html>
biggie 2003-02-19
  • 打赏
  • 举报
回复
把你的提交页面.也贴出来.如果我没说错的话,你的代码没问题.有问题的是在你的提交页面上..把errorPage="" 这里面是不是没值.把这个去掉.在试试
xxjun 2003-02-19
  • 打赏
  • 举报
回复
干脆都贴出来,还需要什么吗
import java.io.*;
import java.sql.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.gjt.mm.mysql.Driver;

public class login extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try {
String DBDriver="org.gjt.mm.mysql.Driver";
String ConnStr="jdbc:mysql://localhost/testdb";
String MyUser="test";
String MyPassword="test";
String SQLstring;
String username;
String password;

username = request.getParameter("username");
password = request.getParameter("password");

Class.forName(DBDriver);
Connection conn = DriverManager.getConnection(ConnStr,MyUser,MyPassword);
Statement stmt = conn.createStatement();

SQLstring = "SELECT * FROM hr where name='"+ username +"'";
ResultSet RS = stmt.executeQuery (SQLstring);
if (RS.next()) {
if ( RS.getString("password").equals(password) ) {
HttpSession session =request.getSession(true);
session.setAttribute("username",username);
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
response.setHeader("Location","ok.jsp");
}
else {
out.print("Password Error");
}
}
else {
out.print("User Not Found");
}

RS.close();

} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
xxjun 2003-02-19
  • 打赏
  • 举报
回复
加了
import java.io.*;
import java.sql.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
chesterwoo 2003-02-19
  • 打赏
  • 举报
回复
噢,我没有看到HttpServlet!
chesterwoo 2003-02-19
  • 打赏
  • 举报
回复
要解决问题,需要更多的信息。
可以肯定的是,你的代码不会有问题。
shkwh 2003-02-19
  • 打赏
  • 举报
回复
必须要扩展extends HttpServlet,所以不认
xxjun 2003-02-19
  • 打赏
  • 举报
回复
ding

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧