开发者

Servlet 3 issues with @WebFilter and @WebServlet deployment

开发者 https://www.devze.com 2022-12-16 17:55 出处:网络
I am trying to migrate my existing servlets and filters defined in web.xml file to @WebServlet and @WebFilter annotations on Glassfish V3 server.

I am trying to migrate my existing servlets and filters defined in web.xml file to @WebServlet and @WebFilter annotations on Glassfish V3 server.

Currently web.xml defined 12 servlets and 6 filters . Tried removing one servlet from web.xml file and added @WebServlet annotation to Java servlet file .

But having diffi开发者_开发技巧culty in accessing the servlet when ever my JSP trying to access Servlet Glassfish complains "Service Not Available".

basically Servlet and filter defined using annotations never identified by Glassfish Server 3.

Is this existing bug that annotations can not be used along with web.xml file ? Do we have any workaround.

I referred following Sun documentation to migrate web.xml to servlet 3 annotations


You've got to get your web.xml correct, below is the beginning of the web.xml you should use:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    metadata-complete="false" 
    version="3.0" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
0

精彩评论

暂无评论...
验证码 换一张
取 消