خرید بک لینک

Vote count: 0

I have a problem: "When I call index.jsp, it's not call severlet page.

(1) index.jsp page:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="HelloServlet"/>
</body>
</html>

(2) servlet/HelloServlet.java class package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.aotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/HelloServlet")
public class HelloServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;


    public HelloServlet() {
        super();
        // TODO Auto-generated constructor stub
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        request.getRequestDispatcher("welcome.jsp").forward(request, response);
    }
}

I hava a page welcome.jsp

<body>
Hello world
</body>

(3) config file web.xml

<?xml version="1.0" encoding="ISO-8859-1"?> 
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
version="2.4"> 

 <welcome-file-list>

        <welcome-file>index.jsp</welcome-file>

    </welcome-file-list>

<servlet> 
<servlet-name>hello</servlet-name> 
<servlet-class>servlet.HelloServlet</servlet-class> 
</servlet> 

<servlet-mapping> 
<servlet-name> hello </servlet-name> 
<url-patte> /welcome</url-patte> 
</servlet-mapping> 

</web-app> 

Thank you for seeing and helping me

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 20 خرداد 1395 ساعت: 10:12

صفحه بندی