找不到Websphere文件错误

时间:2014-05-29 05:14:26

标签: java websphere file-not-found

我是Java的初学者。 我开发了一个接受用户名和密码的jsp页面,然后执行一个验证硬编码值的java页面。 问题是它在Tomcat上运行良好。该网页显示来自java页面的消息。但同样的事情在IBM webshpere上不起作用。当我点击提交按钮时,我收到一个文件未找到错误。 请帮忙。

这是JSP内容:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Example</title>
</head>
<body>
<form name="loginform" action="login" method="post">
<p>Enter User Name: <input type="text" name="getusername"><br>
Enter Password: <input name="getpassword" type="password"><br>
<input type="submit">
</form>

</body>
</html>

=====

这是Java文件内容

package test.ae;


import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
 * Servlet implementation class Login
 */
@WebServlet(description = "Login Servlet", urlPatterns = { "/login" })
public class Login extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public Login()
    {
        super();
    }
    public void init(ServletConfig config) throws ServletException {}

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("Service method of the servlet");
        String username = "user";
        String password = "root";

        String un= request.getParameter("getusername");
        String pw= request.getParameter("getpassword");
        String msg = "";

        if(un.equals(username) && pw.equals(password))
        {
            msg = "Hello " + un;
        }
        else
        {
            msg = "Login failure";
        }

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<font size='6' color=red>" + msg + "</font>");
    }

}

======================

1 个答案:

答案 0 :(得分:0)

您使用的是哪个版本的WebSphere服务器?它是否支持@WebServlet注释(Java Servlet 3.0(JSR 315),它是Java EE 6的一部分)

您可以在web.xml中使用url-pattern代替: http://docs.oracle.com/cd/E13222_01/wls/docs81/webapp/web_xml.html