servlet-3.0

SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer

夙愿已清 提交于 2019-11-27 04:06:31
问题 I am attempting to move a xml-based Spring MVC app to a Java Configuration based app. There appears to be a mismatch with the various java.servlet classes available in maven. For instance, some provide the addServlet() method and some do not. Here is my config class: public class MyWebAppInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext container) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new

How to set tomcat 8 container character encoding of request and response to UTF-8 intead of ISO-8859-1

我的未来我决定 提交于 2019-11-27 03:40:34
问题 We need to set tomcat 8 container character encoding of request and response to UTF-8 intead of ISO-8859-1 , What is the setting for the same We tried setting as mentioned below , https://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1 But that requires creating filter etc. Is there any elegant way where we can just change some configuration set to make it applicable at container level 回答1: Tomcat 8+ comes bundled with a filter to set the character encoding. This is described in Tomcat 8

IllegalStateException: Not supported on AsyncContext.startAsync(req, res)

北战南征 提交于 2019-11-27 03:17:58
问题 I have created a servlet 3.0 to explore asynchronous request processing: @WebServlet(name="MyTest", urlPatterns={"/MyTest"}, asyncSupported=true) public class MyTest extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { AsyncContext tmp = req.startAsync(req, res); ... } } but I get an IllegalStateException when .startAsync(...) is called. I know the Javadoc mentions that exception, but I did explicitly enable

Tomcat 7 session cookie path

无人久伴 提交于 2019-11-27 02:06:51
问题 I'm having a huge problem with my application and Tomcat 7. My application needs to set session cookie to "/" path instead of "/context" path. In tomcat 6 it was a matter of adding another property to Connector (emptySessionPath="true") and Tomcat 7 doesn't recognize this thing. I know that Servlet 3.0 spec allows to configure it on per-context basis, but I couldn't make it work with Tomcat 7. It still adds the context path instead of "/". I will be very grateful for the receipt on how to do

Java web app - What determines my Servlet API version? Does it get specified in web.xml?

半腔热情 提交于 2019-11-27 01:38:50
问题 I'm using Eclipse EE Juno and my current web application is using Dynamic web modules 2.4 . I'm trying to bump the version up to 3.0 but for some reason I'm unable to. when I try to change the version in project facets I get Cannot change version of project facet Dynamic Web Module to 3.0 . Is it possible that there some bunk line in my web.xml file that determines this? How do I change the Dynamic web modules version if not from Eclipse project facet setting alone? 回答1: Servlet 2.4 in web

Java - Async in Servlet 3.0 vs NIO in Servlet 3.1

本秂侑毒 提交于 2019-11-27 00:19:33
问题 Until now, as it applies to serving http requests, I thought the terms - asynchronous and non-blocking i/o meant the same thing. But apparently, they have been implemented separately in servlet 3.0 and 3.1 respectively. I am struggling to understand the difference here... Can someone shed more light on this topic, please? Specifically, I am looking for an example of how a servlet 3.0 implementation of a server can be async, yet block on a thread? I think may be if I understand this, it may be

Servlet-3 Async Context, how to do asynchronous writes?

会有一股神秘感。 提交于 2019-11-26 23:48:17
问题 Problem Description Servlet-3.0 API allows to detach a request/response context and answer to it later. However if I try to write a big amount of data, something like: AsyncContext ac = getWaitingContext() ; ServletOutputStream out = ac.getResponse().getOutputStream(); out.print(some_big_data); out.flush() It may actually block - and it does block in trivial test cases - for both Tomcat 7 and Jetty 8. The tutorials recommend to create a thread pool that would handle such a setup - witch is

How to avoid request set ASYNC_SUPPORTED=true to enable async servlet 3.0 processing on Tomcat 7?

China☆狼群 提交于 2019-11-26 22:58:00
问题 Following an issue reported on this question, a solution was found: req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true); This seems a bit strange and is not really 'portable' code (it won't hurt, but...). It seems specific to Tomcat 7. I am using Tomcat 7.0.14 as delivered by NetBeans 7.0.1. I could not find documentation indicating it is necessary to enable async request processing in servlet 3.0 with a catalina attribute. I could not find documentation indicating something special

Why create new thread with startAsync instead of doing work in servlet thread?

為{幸葍}努か 提交于 2019-11-26 21:07:24
问题 In servlet 3.0 one can use startAsync to put long work in another thread, so that you can free up servlet thread. Seems that I'm missing something, because I don't see, why not just to use servlet thread for working? Is the thread created by startAsync somehow cheaper? 回答1: In most situations when handling requests you are blocking or waiting on some external resource/condition. In this case you are occupying the thread (hence a lot of memory) without doing any work. With servlet 3.0 you can

How to define <welcome-file-list> and <error-page> in servlet 3.0's web.xml-less?

吃可爱长大的小学妹 提交于 2019-11-26 20:46:10
I have existing web-app which I want to convert into web.xml-less of servlet's 3.0. I've managed to make it working, however there are 2 tags in web.xml which I still don't know the equivalent code in web.xml-less environment. <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/pageNotFound</location> </error-page> Any help is appreciated In Servlets 3.0 you don't need a web.xml for many cases, however, sometimes it's required or just useful. Your case is just one of them - there is no special annotations to