我在JSP中的登录表单是:
<form method="post" name="cust_form" id="Cust_form" action="Cust_care" onsubmit="return Cust_check_field()">
//
</form>
我的Servlet是
package p1;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Cust_care extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Cust_care</title>");
out.println("</head>");
out.println("<body>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:movie_pro","sa",".");
String cname=request.getParameter("c_name");
st.executeUpdate();
st.clearParameters();
//
out.println("</body>");
out.println("</html>");
}
catch(Exception e){}
}
这是我的Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd">
<servlet>
<servlet-name>Cust_care</servlet-name>
<servlet-class>p1.Cust_care</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Cust_care</servlet-name>
<url-pattern>/Cust_care</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
我收到错误HTTP状态404,说明请求的资源不可用
**或者我收到错误HTTP Status 500**,说明java.servlet.ServletException:Wrapper找不到servlet p1.cust_care
如果有人有解决方案,请通知
servlet类是否编译?processRequest()方法是从doGet()调用的吗?