-1
我的web.xml文件中的代码启动servlet的contextListener但不能启动该应用程序的index.jsp(主页)
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.vts.action.Server</listener-class>
</listener>
Server.java代码....
public class Server extends HttpServlet implements ServletContextListener {
private static final long serialVersionUID = 1L;
Socket clientsocket;
ServerSocket socket = null;
int PORT = 9090;
@Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
System.out.println("ServletContextListener destroyed");
}
@Override
public void contextInitialized(ServletContextEvent arg0)
{
// hear code create socket server and accept multiple client connection and
String via gps and save string in database is working correctly
}
}
BUT 现在我的问题是我想接受通过gps在后台运行继续字符串
但index.jsp页面未启动认为这是我的欢迎文件。我不知道在我的web.xml监听配置是否正确或错误..... PLZ给建议
感谢&问候
Krishnakant
这不是很清楚你想要什么来实现的,而你的错误。你有一个充当监听器的servlet,但是servlet本身似乎什么都不做。你确定你甚至需要使用一个servlet容器来完成你正在尝试解决的任务吗? – NilsH 2013-03-26 08:42:17
@NilsH似乎他没有共享代码的一部分,而是他写了一条评论:“听到代码创建套接字服务器,并通过gps接受多个客户端连接和字符串,并在数据库中保存字符串正常工作” – Lakshmi 2013-03-26 08:46:56
是的,在contextInitialized中。我的观点是,在servlet中没有获取/发布相关的代码。 – NilsH 2013-03-26 08:51:09