I have read a lot of topics in stackoverflow for solve my problem, but none was useful. When I tried to log in Manager App ([http://localhost:8080/manager/html][1]) using a lot of different configurations, but I always obtained 401 Unauthorized after attempted to log in using the rights credentials. I restart…
Getting Result type in Interceptor
I have Struts 2 actions with different (HTML and JSON ) result types. They use common interceptor. If needed to intercept the request, how to return a result based on given action result type? For example, my Action.ERROR forwards to JSP page. If action is JSON type I want to forward JSON error instead. Answe…
Java 8 Iterable.forEach() vs foreach loop
Which of the following is better practice in Java 8? Java 8: Java 7: I have lots of for loops that could be “simplified” with lambdas, but is there really any advantage of using them? Would it improve their performance and readability? EDIT I’ll also extend this question to longer methods. I…
What is the default package name for Struts in struts.xml?
I created a new class called RegesterAction but I didn’t keep this class in any package. How can I configure this class in the struts.xml? Below is the struts.xml file but I’m unable to understand the attribute values “default” and struts-default. Answer The package name is completely …
Two conditions in one if statement does the second matter if the first is false?
Okay, so I have this piece of code tested and I found there isn’t any exception thrown out. Does the statement here mean that if the first condition is false we don’t even have to check the second condition? Or it equals to ? And, what if it is written in C or python or some other languages? Thank…
Seeking in AES-CTR-encrypted input
As AES in CTR mode is great for random access, lets say I have a data source created with a CipherOutputStream in AES-CTR mode. The library underneath—which is not mine—uses a RandomAccessFile that allows to seek to a specific byte offset in the file. My initial thought would be to use a CipherInputStream wit…
Mockito mock objects returns null
I try to implement some tests for my JSF application and for the mocks I am using mockito. (I also use spring) The test succeeds, but when I want to retrieve the instance with the getInstance method. All Parameters which I have set before (via the constructor before) are null. I am new to mocked objects, so i…
Parser Exception for format EEEE, MMMM d, YYYY h:mm:ss a z
I’m getting parser exception on trying to parse string value: To format: This is the program sample: And this is the error message: this is my sample program Answer From the JodaTime docs: Zone names: Time zone names (‘z’) cannot be parsed. However SimpleDateFormat does support parsing of ti…
Reading a log file which gets rolled over
I am trying to use a simple program to read from a log file. The code used is as follows: The code works well for new lines being added to the log file but it does not replicate the rollover process. i.e. when the content of the log file is cleared I expect the java console to continue reading text
How perform task on JavaFX TextField at onfocus and outfocus?
I am working on JavaFX project. I need to perform some task on a JavaFX TextField. For example on the “on focus” event for the TextField I want to print and on the “out focus” event it should print Answer I thought it might be helpful to see an example which specifies the ChangeListene…