I have a situation in spring batch where I have multiple item processors that make up a composite item processor. I need to share some context data between two processors in the same step. I have found a working solution to access the context, shown below. That said there is an alternate solution that appears…
Unable to get a handle on the body of a multipart/form-data POST request in XPage ServiceBean
I have an xpage based on a bootstrap framework which uses jQuery $post to submit forms contained within the page. These get posted using multipart/form-data content-type so I have no control over that. I have set up a REST.xsp containing a RESTService which calls a java ServiceBean. The latest method I have t…
How to set boundary in RestAssured
I’m trying to create multipart POST call using RestAssured, but I don’t know how to get any boundary there. I tried this code, but it doesn’t work. Log Wanted result: So, how do I get ——WebKitFormBoundary123 in the request multipart form? UPDATE: If I use this: I will get this, w…
change the json object value
I have a json object like above and i want to change apiInvokerPublicKey’s value i did not find a method in gson so how can i change it? EDIT: I used addProperty method from gson but it changes whole “onboardingInformation” i just want to change “apiInvokerPublicKey” Answer You c…
Ant Javac compile subpackage class files to the parent src directory
I would like Ant 1.9 to be able to compile servlet classes to the parent src directory, but the file system has the files in packages. No, the packages are not declared in the servlet files. The code is deployed with all the servlets in the same directory. I supposed I can create an ant copy command to do thi…
why is my primality test failing so often when randomizing a BigInteger?
I wasn’t able to get true for both p and q, most of the results is both false or rarely p is true but q is false, why wouldn’t this test ever be true for both p and q? Answer First of all BigDecimal randomizer = new BigDecimal(Math.random()).multiply(new BigDecimal(bitSize100)) does not result in …
How to access an enum member of a Java interface using Kotlin?
I have a Java interface, and need to access it throught my Kotlin application. But it is not working. // On Java public interface IMyInterface { int TEST_OK = 1; enum MyEnum { NOK(0), …
If statement nested in for loop
I’m trying to create a program that prints “-” if the number is divisible by 2 and “*” if it is not. I get it to print the numbers, – and *, but it is not printing – and * in place of the number, if that makes sense? I can’t understand where exactly I’m go…
Why is this lambda expression cast using an ampersand?
recently I stumbled over the following code in the Java Comparator class: What’s confusing me is the (Comparator<T> & Serializable) part. Since the method only returns a Comparator I don’t see the use in casting to Serializable. I also don’t see the reason to ever cast anything thi…
Create a stream that is based on a custom generator/iterator method
How can I create a Stream that creates a number of items based on a custom generate() method? The question is different from the one referred to. The final result is a Stream, so I could (simplistically) use a “.forach( System.out::println)”. An example would be: Stream.generate( myGenerateMethod)…