我知道这个话题有几个问题。有些事情没有用。有些事情我不明白。您能否详细解答我的问题和答案。
我有两个项目 1.银行客户 - 动态网络项目 - >它有我所有的jsp文件,找不到主页,web.xml看起来像这样
?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>BankClient
</display-name>
<welcome-file-list>
<welcome-file>HomePage.html</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>ControllerServlet</display-name>
<servlet-name>ControllerServlet</servlet-name>
<servlet-class>controllerServlet.ControllerServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ControllerServlet</servlet-name>
<url-pattern>*.maadi</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>1</session-timeout>
</session-config>
</web-app>
一个BankServer项目,它包含我的所有类和接口文件,包括ControllerServlet类,如下所示:
package controllerServlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import service.Service;
import service.ServiceImpl;
import bean.DepositBean;
import bean.LoginBean;
import bean.RegBean;
import bean.WithdrawBean;
import constants.Constants;
public class ControllerServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public ControllerServlet() {
super();
System.out.println("In the CSERVE con");
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("In do get");
process(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("In do post");
process(request,response);
}
private void process(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
System.out.println("In process");
try
{
String uri = request.getRequestURI();
System.out.println("uri = "+uri);
Service si=new ServiceImpl();
if(uri.contains("/openRegisterView"))
{
System.out.println("inside openregisterview controlling block");
RequestDispatcher rd = request.getRequestDispatcher("Register.jsp");
rd.forward(request,response);
}
if(uri.contains("/register"))
{
System.out.println("inside register controlling block ");
RegBean rb = (RegBean) request.getAttribute("reg");
System.out.println("before calling register() of Model");
String result = si.register(rb);
System.out.println("result returned by executing models register = "+result);
RequestDispatcher rd = null;
if(result.equals(Constants.SUCCESS))
{
rd = request.getRequestDispatcher("/Success.html");
rd.forward(request, response);
}
else
{
request.setAttribute("errorMsg", result);
rd = request.getRequestDispatcher("/Register.jsp");
rd.forward(request, response);
}
}
if(uri.contains("/openLoginView"))
{
System.out.println("inside openloginview controlling block");
RequestDispatcher rd = request.getRequestDispatcher("Login.jsp");
rd.forward(request,response);
}
if(uri.contains("/login"))
{
System.out.println("inside login usecase controlling block");
LoginBean lb = (LoginBean) request.getAttribute("log");
String result = si.authenticate(lb);
RequestDispatcher rd = null;
if(result.equals(Constants.SUCCESS))
{
HttpSession session = request.getSession(true);
lb.setPwd("");
session.setAttribute("user", lb);
rd = request.getRequestDispatcher("/Welcome.jsp");
rd.forward(request, response);
}
else
{
request.setAttribute("errorMsg", result);
rd = request.getRequestDispatcher("/Login.jsp");
rd.forward(request, response);
}
}
if(uri.contains("/openWithdrawView"))
{
System.out.println("inside openWithdrawView controlling block");
RequestDispatcher rd = request.getRequestDispatcher("Withdraw.jsp");
rd.forward(request,response);
}
if(uri.contains("/withdraw"))
{
System.out.println("inside withdraw usecase controlling block");
WithdrawBean wb = (WithdrawBean) request.getAttribute("wit");
LoginBean lbb=(LoginBean) request.getSession().getAttribute("user");
si.draw(wb,lbb);
RequestDispatcher rd=null;
rd = request.getRequestDispatcher("/Success.html");
rd.forward(request,response);
}
if(uri.contains("/openDepositView"))
{
System.out.println("inside openWithdrawView controlling block");
RequestDispatcher rd = request.getRequestDispatcher("Deposit.jsp");
rd.forward(request,response);
}
if(uri.contains("/deposit"))
{
System.out.println("inside deposit usecase controlling block");
DepositBean db = (DepositBean) request.getAttribute("dep");
LoginBean lbb=(LoginBean) request.getSession().getAttribute("user");
si.add(db,lbb);
RequestDispatcher rd=null;
rd = request.getRequestDispatcher("/Success.html");
rd.forward(request,response);
}
}
catch(Exception e)
{
e.printStackTrace();
RequestDispatcher rd = null;
request.setAttribute("errorMsg", "Error "+e.getMessage());
rd = request.getRequestDispatcher("/Error.jsp");
rd.forward(request, response);
}
}
}
我已将BankServer项目导出到一个jar文件中,并在我的BankClient项目中添加了相同的内容并配置了构建路径。
我已经在BankClient项目中复制了必要的jar文件(servlet-api.jar和BankServer.jar)。
我已经尝试清除工作目录并重新启动eclipse。
我的控制台看起来像这样
我的控制台看起来像这样
2012年10月18日下午11:01:44 org.apache.catalina.core.AprLifecycleListener init INFO:基于APR的Apache Tomcat Native库允许 在生产环境中找不到最佳性能 java.library.path:C:\ Program 文件\的Java \ JRE6 \ BIN; C:\ WINDOWS \太阳\的Java \ BIN; C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:/程序 文件/的Java / JRE6 /斌/客户端; C:/程序 文件/的Java / JRE6 /箱; C:\ Windows \ System32下; E:\ ORACLE \产品\ 10.2.0 \ DB_1 \ BIN; C:\ PROGRAM 文件\的Java \ jdk1.6.0_23 \斌;;。 2012年10月18日下午11:01:44 org.apache.tomcat.util.digester.SetPropertiesRule开始警告: [SetPropertiesRule] {服务器/服务/引擎/主机/上下文}设置 属性'source'到'org.eclipse.jst.j2ee.server:BankClient'没有 找到匹配的财产。 2012年10月18日下午11:01:44 org.apache.tomcat.util.digester.SetPropertiesRule开始警告: [SetPropertiesRule] {服务器/服务/引擎/主机/上下文}设置 属性'source'到'org.eclipse.jst.j2ee.server:Obank'没找到 匹配的财产。 2012年10月18日下午11:01:45 org.apache.coyote.http11.Http11Protocol init INFO:正在初始化Coyote HTTP-1.1 on http-8080 Oct 18,2012 11:01:45 PM org.apache.catalina.startup.Catalina加载INFO:初始化 处理时间为434 ms 2012年10月18日下午11:01:45 org.apache.catalina.core.StandardService start INFO:启动服务 Catalina Oct 18,2012 11:01:45 PM org.apache.catalina.core.StandardEngine start INFO:启动Servlet 引擎:Apache Tomcat / 6.0.35 2012年10月18日下午11:01:45 org.apache.coyote.http11.Http11Protocol start INFO:启动Coyote HTTP-1.1 on http-8080 Oct 18,2012 11:01:45 PM org.apache.jk.common.ChannelSocket init INFO:JK:ajp13正在收听 /0.0.0.0:8009 Oct 18,2012 11:01:45 PM org.apache.jk.server.JkMain 启动信息:Jk运行ID = 0时间= 0/16 config = null 2012年10月18日 11:01:45 PM org.apache.catalina.startup.Catalina启动INFO:Server 在240毫秒启动
可能是什么问题?我是新手。请详细解释
如果这不是发布问题的正确方法,请原谅我。这是我第一次来这里。
非常感谢