Skip to content

Is it fine to do logs in java class with thread id?

When we add logs in to the java class (using log4j), Is it fine to add thread id with that log messages? is it a bad practice? My idea was to add this thread id; Once we examine a log file of a multithreaded application, it is difficult to find out the correct flow using logs. (As an example, say

Create and populate TreeMap in one line

Like an array new Integer[]{ 1, 2, 3 }, can I create and populate a TreeMap using just one line? Any chances for HashMap or LinkedHashMap too? Answer There is no built-in syntax for specifically initializing maps. However, you can take advantage of a special syntax known as “double brace initialization&…

Convert string to List

I have a string with comma separated value that I am getting direclty from database. Now I want to pass that entire string to another query but the datatype required is long and i want to use in clause to get this done. Is there any direct way to do it instead of looping. Answer With guava: EDIT: With a

Are server 500 errors a security issue?

I’ve found that it’s possible to cause 500 errors on a server using curl and a faked GWT-Permutation with a POST payload. The payload is generating a java.lang.Exception on an Apache server. Does this open up a security issue? Should I report it to Google’s GWT support? To clarify the questi…

Selecting Nth-of-type in selenium

I’m trying to use By.cssSelector to grab the nth dom element with class c3 with a structure like this: Testing my CSS selectors, I’m becoming increasingly confused. This selector selects the 2nd instance of c2/c3 correctly: while: select nothing. Even worse, translating this into selenium, I seem …

Jaas Basic Authentication tomcat 7

I keep on getting the same error, I have already changed the tomcat7w file that specifies the jaas config file location I have already added this tom my tomcat7w.exe file. another is that I also have this realm so what am I missing? please help me, I am using netbeans, tomcat 7.0.47. I have resolved to using …