servlet-3.0

Call Asynchronous Servlet From AJAX

此生再无相见时 提交于 2019-12-10 09:47:06
问题 What I am trying to accomplish is not too complex, but I am having a bit of trouble as I am not well versed in AJAX. When it is implemented, I will have a JSP that has a button which invokes an Asynchronous Servlet. The servlet will run a long running task and provide dynamic feedback to the user by adding rows to a table when parts of the task are completed. Before I attempt to write the final version, I am doing a proof of concept to get an understanding of how this will work. However, I'm

Programmatic access to MultiPartConfig in Servlet 3.0

北城余情 提交于 2019-12-09 12:16:25
问题 I use Servlet 3 @MultiPartConfig annotation to implement file upload in my application. I need set multipart-config location parameter at the runtime (not hardcode in annotaion parameter). Is there any API for programmatic access to multipart-config of servlet? Thanks 回答1: The @MultiPartConfig is really just a marker interface for the container. When the servlet is initialized the annotation values provided are mapped to it with a proxy object. When the incoming request is a multipart/form

Java Servlet 3.0 server push: Sending data multiple times using same AsyncContext

倖福魔咒の 提交于 2019-12-08 23:35:36
问题 Lead by several examples and questions answered here ( mainly http://www.javaworld.com/javaworld/jw-02-2009/jw-02-servlet3.html?page=3 ), I want to have server sending the response multiple times to a client without completing the request. When request times out, I create another one and so on. I want to avoid long polling, since I have to recreate request every time I get the response. (and that quite isn't what async capabilities of servlet 3.0 are aiming at). I have this on server side:

Glassfish - Preserve sessions across redeployment - SessionListener is not called on session recreation

半城伤御伤魂 提交于 2019-12-08 03:55:58
问题 So I made a simple session listener - there are many on the web : import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; @WebListener class SessionListener implements ServletContextListener, HttpSessionListener { private static final int MAX_INACTIVE

How does spring-boot able to serve specific url?

一世执手 提交于 2019-12-08 02:05:53
问题 In my previous experience: When using pure servlet , we define servlets so that it will serve requests that match specific urls. When using struts2 , we define a filter so that it will serve requests that match specific urls. When using springMVC in a traditional xml configuration style, we define a dispatcher servlet so that it will serve requests that match specific urls. But with spring-boot : Seems no servlet or filter is defined explicitly. But it still could serve specific urls. The

Get AsyncContext from HttpServletRequest

若如初见. 提交于 2019-12-07 16:38:22
问题 I'm using Spring's OncePerRequestFilter overriding shouldNotFilterAsyncDispatch method to return false. This way it can handle asynchronous requests. In the filter I'm trying to do the following: if (isAsyncDispatch(request)) { request.getAsyncContext().addListener(new AsyncListener() { @Override public void onComplete(AsyncEvent event) throws IOException { System.out.println("onComplete"); } @Override public void onTimeout(AsyncEvent event) throws IOException { } @Override public void

How do I configure Tomcat and HAProxy to work with the WebSocket Framework Atmosphere?

≯℡__Kan透↙ 提交于 2019-12-07 14:32:47
问题 I have a Java application running on Tomcat7, which uses the Atmosphere Framework. Atmosphere is a Websocket Framework. I used a sample application from the Atmosphere Sample Chat. My problem is that I did not get the connectors as well as the proper configuration for my Websocket Atmosphere application running. The questions I have are: How do I have to configure my HAProxy? How do I have to configure my Tomcat server? How do I have to configure Tomcat for APR and for the NIO connector? Do I

JAX-RS and Long Polling

强颜欢笑 提交于 2019-12-07 10:36:16
问题 I'm trying to use long polling with JAX-RS (Jersey implementation) and it doesn't work as I expect. Maybe I'm misunderstanding something. I would appreciate any advice. Please note that using a reverse connection (something like Atmosphere, Comet, etc) is not a option for security reason. Not that I'm currently developing with Tomcat 7. The following method is invoked from a JQuery Ajax call (using $.ajax ). @Path("/poll") @GET public void poll(@Suspended final AsyncResponse asyncResponse)

Disable @WebFilter (embedded in dependency jar)

微笑、不失礼 提交于 2019-12-07 10:33:05
问题 Is there a way to disable a embedded Servlet Filter? My project has a dependency jar that contains (inside the jar) a @WebFilter mapped to "/*" . I need the jar (it has a lot of commons class of my company), but this new project does not need this WebFilter, actually this new project will not work because this Filter checks user authentication and the new project has no "loggedUser". It's like a website Thanks 回答1: web.xml takes precedence over annotations for precisely this reason. Simply

Glassfish - Preserve sessions across redeployment - SessionListener is not called on session recreation

落花浮王杯 提交于 2019-12-07 01:00:36
So I made a simple session listener - there are many on the web : import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; @WebListener class SessionListener implements ServletContextListener, HttpSessionListener { private static final int MAX_INACTIVE_INTERVAL = 1000; // in secs // static AtomicInteger numOfSessions; // singleton ? static ? static int