我试图创建一个简单的Websphere项目,但始终出现错误。我不确定我要去哪里。我已经用谷歌搜索了类似的问题,但我似乎没有一个适合我,因为我不断遇到同样的错误。
我试图以各种方式解决该问题,并添加了一个丢失的web.xml文件,但它似乎仍然无法正常工作,而且我不确定我要去哪里。
/**
* Servlet implementation class RegisterServlet
*/
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public RegisterServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String FNAME = request.getParameter("FNAME");
String LNAME = request.getParameter("LNAME");
String MSISDN = request.getParameter("MSISDN");
String AMB = request.getParameter("AMB");
Connection connection = null;
try {
connection =DriverManager.getConnection("jdbc:mysql://localhost/ussd","root","root1215");
PreparedStatement ps = connection.prepareStatement("INSERT INTO USERDETAILS (FNAME, LNAME, MSISDN, AMB) VALUES (?, ?, ?, ?)");
ps.setString(1, FNAME);
ps.setString(2, LNAME);
ps.setString(3, MSISDN);
ps.setString(4, AMB);;
int i = ps.executeUpdate();
if (i > 0)
System.out.println("You are successfully registered...");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
if(connection !=null) {
try {
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
//**************** web.xml code********************
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>RegisterServlet</servlet-name>
<display-name>RegisterServlet</display-name>
<description></description>
<servlet-class>com.web.servlet.RegisterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegisterServlet</servlet-name>
<url-pattern>/RegisterServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>