我有tomcat 7.0.14,jdk1.6和Eclipse Indigo for Java EE Web应用程序开发人员。 我是JSP新手,所以尝试过Eclipse,因为我认为它使编码变得更容易。我紧跟着this video tutorial。Eclipse Indigo中的Servlet JSP连接问题
我在我的项目prison- login.java,home.html和修改过的web.xml下创建了2个文件。 当我点击登录提交按钮(这是第1页)页面,它仅显示这样的错误:
File not found
Firefox can't find the file at /D:/eclipse/Workspace/Prisonhome/WebContent/WEB-INF/Log?user=sa&pass=sa&action=That's+me.
我不知道这是否是不足以拯救项目工作区。
视频和我的Eclipse文件中给出的文件位置之间存在若干差异。例如:我的Eclipse中的web.xml
位于servers-> apache-tomcat目录中,而不是Web内容 - > WEB_INF-> lib-> web.xml。是不是重要?
我的代码: 的index.html
<html>
<head>
<title> Welcome :) </title>
</head>
<body>
<form action="Log" method="get">
<B>
<br><br><br><br><br><br><br><br><br><br><br><br>
Username: <input type=text name="user"><br><br>
Password: <input type=text name="pass"><br><br>
<input type=submit name=action value="That's me" style="background-color:666666; color:ffffff; border-color:ee0088">
</B></font>
</form>
</body>
</html>
Login.java:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uname=request.getParameter("user");
String passwd=request.getParameter("pass");
response.getWriter().println("<html><head>This is the response!</head>");
response.getWriter().println("<body>Response!!</body></html>");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
的web.xml:
<servlet>
<servlet-name>Log</servlet-name>
<servlet-class>org.prisonhome.packs.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Log</servlet-name>
<url-pattern>/Log/*</url-pattern>
</servlet-mapping>
请注意,如果答案适合您,您应该将其标记为已接受。 – Bozho 2011-06-01 15:55:00