servlet-3.0

Resteasy deploy fails randomly on glassfish 4.1

一世执手 提交于 2019-12-06 15:52:42
I have a problem with my REST-Application using Resteasy. When I deploy the application with this dependencies <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-servlet-initializer</artifactId> <version>3.0.11.Final</version> </dependency> as described here in Chapter 3.5 sometimes the server deploys the application correctly and everything works fine. But sometimes I get Error invoking ServletContainerInitializer org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer java.lang.NullPointerException at org.jboss.resteasy.plugins.servlet.ResteasyServletInitializer

How to use @WebServlet to accept arguments (in a RESTFul way)?

痞子三分冷 提交于 2019-12-06 14:56:58
suppose that I want to accept the following urls: http://myserver/myapplication/posts http://myserver/myapplication/posts/<id> http://myserver/myapplication/posts/<id>/delete how can I use the servlet decorator @WebServlet to do so? I'm investigating value and urlPatterns but I don't get how to do so. For example, @WebServlet(urlPatterns={"/posts", "/posts/*"}) [..] String param = request.getPathInfo(); gives me some result, but how to use it? Also, request.getPathInfo() seems to return the value of the wildcard, but what if I want more parameters like in http://http://myserver/myapplication

Spring 3.1 - Servlet 3 code-based configuration using the Jetty Maven Plugin

眉间皱痕 提交于 2019-12-06 11:15:51
问题 I try to integrate the new features of spring 3.1 using annotations to specify the configuration information for the web application. I set up the maven-jetty-plugin version 8.0.4.v20111024 to run my app. While starting jetty using the mvn jetty:run command, everything seems to be ok and set up correctly. But when accessing the app through the browser, there is just the output of the default servlet. It seems to be a simular issue, that tomcat had in previous versions (<=7.0.14) https:/

Getting rid of web.xml in Vaadin 7 with VaadinServlet

会有一股神秘感。 提交于 2019-12-06 11:12:49
问题 I'm new to Java and Vaadin. A basic Vaadin project is using web.xml for all the mappings. If I want to use the @WebServlet annotation I need to create an inner class which somewhere inherits from HttpServlet . @SuppressWarnings("serial") public class VaadinplaygroundUI extends UI { @WebServlet(urlPatterns="/Helo") public static class Servlet extends VaadinServlet { } @Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); I know, I'm missing

Java - Dynamically Adding URL Pattern to a Servlet

大城市里の小女人 提交于 2019-12-06 10:25:33
问题 Is it possible to add a URL pattern to a Servlet dynamically at runtime? For example, when the Servlet starts up, scan a folder for annotations, and then inject those url patterns into the servlet? to provide more clarity - In the Servlet's init file, I want to do this (pseudo-code) // scan all the files in the package my.project.services // find all the classes with the Annotation @Service // read those annotations, find the url patterns in them, and insert them into the servlet 回答1: I'm not

The method getSubmittedFileName() is undefined for the type Part

与世无争的帅哥 提交于 2019-12-06 06:04:40
问题 I am trying to upload multiple files in servlet 3.0> .So this is my code.I am geting an error at getSubmittedFileName() method. Dont know why.Help!! protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String description = request.getParameter("description"); // Retrieves // <input // type="text" // name="description"> Part filePart = request.getPart("file"); // Retrieves <input type="file" // name="file"> String fileName =

How to set secure flag on cookie programatically

混江龙づ霸主 提交于 2019-12-06 05:39:59
问题 I know we can do something like this: <session-config> <cookie-config> <secure>true</secure> </cookie-config> </session-config> But what I want to achieve is to set this flag (true or false) based on some config. Should we use a filter and how ? Thanks 回答1: Assuming that you are in a servlet 3.0+ environment, and you don't want to use web.xml to specify the cookie-secure-flag but set it programmatically: Implement a ServletContextListener and register it in the web.xml or via annotation. In

Glassfish - uploading images - doing it right

隐身守侯 提交于 2019-12-06 04:10:14
问题 I am on latest glassfish (3.1.2) - so no need for apache FileItem and no bugs with getPart(). I read that the best practice on uploading images is saving them on the file system (see here for instance). I am editing already existing code - smelly at that - so I had the idea to do : Part p1 = request.getPart("file"); System.out.println("!!!!!P1 : " + p1); Prints : !!!!!P1 : File name=DSC03660.JPG, StoreLocation=C:\_\glassfish3\glassfish\domains\domain1\generated\jsp\elkethe\upload_7cb06306

Get AsyncContext from HttpServletRequest

。_饼干妹妹 提交于 2019-12-06 03:50:42
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 onError(AsyncEvent event) throws IOException { System.out.println("onError"); } @Override public void

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

Deadly 提交于 2019-12-06 01:41:08
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 have to change something in my app (i.e., my web.xml)? How do I have to fix the errors below? This