Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml Tomcat6和7动态web项目eclipse_Xml_Eclipse_Jsp_Tomcat_Servlets - Fatal编程技术网

Xml Tomcat6和7动态web项目eclipse

Xml Tomcat6和7动态web项目eclipse,xml,eclipse,jsp,tomcat,servlets,Xml,Eclipse,Jsp,Tomcat,Servlets,我正在尝试在localhost服务器上运行动态web项目。i、 e(日食上的tomcat)。但是它显示错误404。它找不到index.jsp文件。我已尝试更改端口,重新检查web.xml,但错误仍然存在。那么我应该做些什么来纠正这个错误呢 这是我的web.xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns

我正在尝试在localhost服务器上运行动态web项目。i、 e(日食上的tomcat)。但是它显示错误404。它找不到
index.jsp
文件。我已尝试更改端口,重新检查
web.xml
,但错误仍然存在。那么我应该做些什么来纠正这个错误呢

这是我的
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" 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>My_Asap</display-name>


<!-- 
    <servlet>
        <description></description>
        <display-name>MyServlet</display-name>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>asap_pkg.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/servlet/MyServlet</url-pattern>
  </servlet-mapping>
 -->
  <welcome-file-list>
     <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

首先在eclipse中转到服务器选项卡,然后执行以下步骤:-

1> 右键单击Tomcat,然后单击属性

2> 单击开关位置,然后单击“确定”

3> 双击Tomcat

4> 在服务器位置选项卡中选择“使用Tomcat安装”选项


然后重新启动Tomcat

您的目录结构是什么?index.jsp驻留在哪里?src->asappkg->myservlet src->dao->db web-inf->lib->web.xml-webinf->index.jsp将index.jsp移出web-inf文件夹。@SaifAsif谢谢。。。成功了:)
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">

        <title>My JSP 'index.jsp' starting page</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">    
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    </head>

        <body>
             This is my JSP page. <br>

        <form action ="servlet/MyServlet">
        <input type="submit" value='send'>
        </form>

        </body>
</html>