Reputation: 2863
Instead of servlet mapping in the web.xml, i'm trying to use annotation to map the servlet to urls as follows:
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(name = "GuestbookServlet", urlPatterns = "/guestbook")
public class GuestbookServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
}
}
And I have also declared the 3.0 spec for servlet in web.xml:
<?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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="false">
</web-app>
However, when I run it on my local environment the response returned is 404.
It works however if I just map the servlets in the web.xml. What am I doing wrong? Does GAE still not support 3.0 specs?
Upvotes: 0
Views: 2074
Reputation: 3873
Servlet 3.1 are now supported on AppEngine.
... In addition to support for an updated JDK and Jetty 9 with Servlet 3.1 specs...
Announcement: https://cloudplatform.googleblog.com/2017/06/Google-App-Engine-standard-now-supports-Java-8.html
Upvotes: 0
Reputation: 1822
Servlet 3.0 spec is not supported by GAE/J
It's still on the roadmap: https://developers.google.com/appengine/docs/features#roadmap_features
You can star this issue to help show your support for this feature: https://code.google.com/p/googleappengine/issues/detail?id=3091
This ticket has been opened a lonnnggg time though.
Upvotes: 5
Reputation: 4474
When I run the following JSP code,
Server info == <%=application.getServerInfo()%><br/>
Major==<%=application.getMajorVersion()%><br/>
Minor==<%=application.getMinorVersion()%><br/>
JSP version is <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion()%><br/>
I see
Server info == Google App Engine/Google App Engine/1.8.1 Major==2 Minor==5 JSP version is 2.1
You could run it for yourself.
Upvotes: 0