servlet-3.0

How to set secure flag on cookie programatically

我的梦境 提交于 2019-12-04 11:31:26
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 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 its contextInitialized method evaluate your secure flag from your config and set it on the

Glassfish - uploading images - doing it right

大城市里の小女人 提交于 2019-12-04 10:10:24
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_138b413999a__7ffa_00000000.tmp, size=2589152bytes, isFormField=false, FieldName=file newlines mine. In the

java applet fail when launched with server “incompatible magic value 1013478509”

空扰寡人 提交于 2019-12-04 04:05:42
问题 I'm having a problem with my applet. I have a school project where I'm supposed to make a pong-online game. It runs fine offline but when I try to load it from a server I just get an empty frame with a red text in it. when I click the text I get the message: incompatible magic value 1013478509 I'm using jetty-all-8.1.8.v20121106.jar, and servlet-api-3.0.jar The class that starts up the server looks like this: public class TheServer extends HttpServlet { private static final long

How to programmatically setup a <security-constraint> in Servlets 3.x?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 03:01:56
问题 In my current web application I am trying to get rid of web.xml and I have not been able to properly setup the security constraint that forces all requests to the application to use HTTPS. <security-constraint> <web-resource-collection> <web-resource-name>all</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> How can I turn the above web.xml

Form login in a Servlet 3.0 using annotations

て烟熏妆下的殇ゞ 提交于 2019-12-04 01:48:47
问题 I have an old servlet ABC using a web.xml to define it's form login (which is another servlet XYZ stored in another JAR file and integrated in the WAR under path WEB-INF\lib): <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/login</form-login-page> <form-error-page>/login?event=Retry</form-error-page> </form-login-config> </login-config> Now I migrated servlet ABC using the new Servlet 3.0 annotations. I have a @WebServlet and a @ServletSecurity annotation.

Spring Boot does not honor @WebServlet

☆樱花仙子☆ 提交于 2019-12-04 01:41:23
I created a Servlet (extending from HttpServlet) and annotated as per 3.0 specs with @WebServlet(name="DelegateServiceExporter", urlPatterns={"/remoting/DelegateService"}) My @Configuration class in Spring Boot scans this servlet's package. However, it does not log that it has deployed this servlet in the embedded Tomcat 8.0.15 container when my Spring Boot application starts up. So, I added @Component to my servlet as well. Now, Spring Boot registers the servlet (proving to me that the scan package was correctly set up), but then it registers it with a URL pattern based on a class name using

Jetty addFilter with Spring Security and no web.xml

為{幸葍}努か 提交于 2019-12-03 12:06:21
问题 Normally I would have added org.springframework.web.filter.DelegatingFilterProxy with a snippet like this to web.xml: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> But with Servlet 3.0 Container and Jetty, I've removed web.xml. I'm trying to add DelegatingFilterProxy

Configuring OpenSessionInViewFilter with Spring 3 and Servlet 3

我的梦境 提交于 2019-12-03 09:16:47
问题 i want to configure OpenSessionInViewFilter to able to use hibernate lazy initialization in view, so i added the filter definition in web.xml, but it doesn't work i still get the same lazy initialization exception, here's what i did: <?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">

Spring: Why “root” application context and “servlet” application context are created by different parties?

北城余情 提交于 2019-12-03 07:28:18
问题 As I understand, a Spring based web application is initialized as below: Step 1 : Servlet container (e.g. Tomcat) locates the implementation of ServletContainerInitializer , which is SpringServletContainerInitializer . Step 2 : SpringServletContainerInitializer creates DispatcherServlet and ContextLoaderListener Step 3 : DispatcherServlet creates servlet application context . And ContextLoaderListener creates root application context . Step 1 is defined by Servlet 3.0 spec. Step 2, 3 are

Difference between async servlet long poll and bayeux protocol (Comet)

梦想与她 提交于 2019-12-03 06:20:45
问题 What is the difference between a simple Async servlet and the Comet / Bayeux protocol? I am trying to implement a "Server Push" (or "Reverse Ajax") kind of webpage that will receive updates from the server as and when events occur on the server. So even without the client explicitly sending a request, I need the server to be able to send responses to the specific client browser. I understand that Comet is the umbrella term for these kind of technologies; with 'Bayeux' being the protocol. But