servlet-3.0

Java - Async in Servlet 3.0 vs NIO in Servlet 3.1

坚强是说给别人听的谎言 提交于 2019-11-28 16:54:32
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 easier to understand the exact problem that the non-blocking i/o in servlet 3.1 is trying to solve.

What's the purpose of AsyncContext.start(…) in Servlet 3.0?

余生长醉 提交于 2019-11-28 16:44:40
Servlet API says about "AsyncContext.start": void start(java.lang.Runnable run) Causes the container to dispatch a thread, possibly from a managed thread pool, to run the specified Runnable. The container may propagate appropriate contextual information to the Runnable. From this description it's not clear how does it relate to task of optimizing thread usage when job requires waiting. In "Servlet & JSP", Budi Kurniawan gives example of Servlet 3.0 async features, where he uses AsyncContext.start , I'll show simplified version of the example: public void doGet(...) { final AsyncContext

Unable to deploy SlingServlet in CQ

荒凉一梦 提交于 2019-11-28 14:01:16
I'm trying to create a servlet in CQ to access some back-end services. Then from my page will make an AJAX call to get the response from servlet. @Component(immediate = true, metatype = false, label = "feedServlet") @Service(Servlet.class) @Properties(value = { @org.apache.felix.scr.annotations.Property(name = "sling.servlet.methods", value = "POST"), @org.apache.felix.scr.annotations.Property(name = "sling.servlet.resourceTypes", value ="/bin/feedServlet/"), @org.apache.felix.scr.annotations.Property(name = "sling.servlet.selectors", value ="POST"), @org.apache.felix.scr.annotations.Property

Cordova POST - Request Forbidden 403. Not reaching Dispatcher Servlet

假如想象 提交于 2019-11-28 11:43:53
I am developing a Cordova application. When I submit an $.ajax POST request from the Cordova app running on my physical device (not emulator) I receive a status code 403 forbidden. I can make a GET request from the device no problem. I can also login using a POST (receiving a 302 Found Response). Requests from Chrome are handled perfectly. I am using Spring / Tomcat. I have added CORS filter to my tomcat web.xml, and have added allow-origins * to my config.xml in Cordova. Below is the log extracts produced when I make the POST request, first from Chrome, secondly from my Device. Chrome Request

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

偶尔善良 提交于 2019-11-28 11:43:36
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 Tomcat 8+ comes bundled with a filter to set the character encoding. This is described in Tomcat 8 Container Provided Filters . This filter needs to be configured in your web.xml file plus a few other changes as

Tomcat 7 session cookie path

人走茶凉 提交于 2019-11-28 08:11:12
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 it. Juts put the sessionCookiePath="/" attribute into your context.xml root node: <Context ...

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

纵饮孤独 提交于 2019-11-28 06:50: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? Servlet 2.4 in web.xml : <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001

What to do with annotations after setting metadata-complete=“true” (which resolved slow Tomcat 7 start-up)?

给你一囗甜甜゛ 提交于 2019-11-28 03:20:11
Seems like the slow Tomcat 7 startup problem can be resolved with "metadata-complete" set to "true" in the web.xml, like so: <?xml version="1.0" encoding="UTF-8"?> <web-app metadata-complete="true" id="WebApp_ID" version="3.0"... The problem is that Tomcat scans for annotations at startup, and this significantly slows it down. My time is cut down from 25 secs to 5 secs. (More info here: Tomcat and Servlet 3.0 Web Configuration ) However, I have some annotations in my code, like: @ManagedBean @RequestScoped @Override ... I am confused - will my code work after I have set metadata-complete="true

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

好久不见. 提交于 2019-11-28 02:45:38
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 generally the counter-positive to a traditional 10K architecture. However if I have 10,000 open

MultipartConfig with Servlet 3.0 on Spring MVC

白昼怎懂夜的黑 提交于 2019-11-28 01:13:16
问题 How do I add in multipart configuration to a spring mvc app which uses controllers with methods annotated with RequestMapping? Background: I want to enable csrf protection and so have added the security:csrf tag in my spring config. I have a controller class with a method annotated with RequestMapping used for uploading files. I also followed the caveat instructions around multipart whereby I added the multipart filter above the security filter. When I tried to upload a file after adding the