Skip to content

Only some URLs not loading in Webview

Code Im trying to load this URL in webview and the webview is empty. What’s wrong with this URL? I tried replacing the URL with other links and it works perfectly. Answer It’s been a SSL handshake failed for HTTPS URL. for debugging the webview, pls add following line and you can inspect webview U…

Java Looking for specific letters in a sting

I was wondering how to iterate over a string and to check how many hi’s come out For example, if the string is “hihi” the count should output 2. This is what I have so far Answer You compare instances (like String) with .equals (not ==). However, here you can use == with String.charAt(int). …

TransformerFactory still vulnerable to XXE attacks

I have a method like below. I’ve set the FEATURE_SECURE_PROCESSING to true. When I run my unit test below, I can list the files under project directory, meaning it is vulnerable to XXE attacks. How can I secure the TransformerFactory to such attacks? Answer You’re supplying a DOMSource to the Tran…

Read hashmap nested properties dynamically

I have the JSON below: I turned this JSON into a Java HashMap using the Gson library. I need to dynamically read some properties of this created hashmap. Ex: title, name of contact and name of company. Sometimes these properties (title, name of contact and name of company) can be inside lists. Below my code: …