Archive for the ‘tricks’ Category

HTTP Status 408 errors, SSL, Tomcat

September 27, 2018 Leave a comment

It took me a while to find the root cause of a problem logging into a web site running Tomcat from FireFox. I thought, this post would help others to find the root cause quickly and prevent this problem in the future when you design web applications.

If I enter a wrong username/password pair, it responds with a correct error. However, when I use the correct pair, I get “HTTP Status 408 – Request Timeout”. My search on Google returned a lot of results, but not helpful at all. Using Chrome from a different machine did not trigger this problem. So Firefox became the culprit.

Using the Web Developer Inspector I noticed that the original JSESSIONID cookie was not submitted back to j_security_check. I thought this is because I was using HTTPS and the cookie was “HttpOnly” with no “Secure”. That appeared to be a red herring.

The root cause was actually very simple. The second level domain set too many cookies, above the 4096 bytes limit. Tomcat was hosted behind a load balancer with a third level domain bound to it. For Chrome this limit seems to be higher. So the solution was to delete those second level domain cookies in FireFox (Click on the site information icon (“i” in a circle) in the address bar, chick on “>” and then “More Information”. Choose the “Security” tab, “View Cookies”. Select the cookies you want to delete. Use the Shift key if you want to delete more than 1. Then click “Remove Selected”).

How to prevent this problem in the future? If you have control on cookies set by a server handling your site on the second level domain and have subdomains, limit the size and the number of cookies that server sets. There is nastier problem lurking here. Suppose, you had enough to store just the JSESSIONID cookie and you hit the limit. Then if you attempt to set other cookies, the browser would quietly drop them on the floor and your web application might malfunction. One way to solve it is actually to check whether you get the cookie you just set. If your application did not get it back and your cookie is critical for your application, show a user-friendly page with an instruction how to clear cookies.


Chrome Browser History By Date

April 29, 2014 Leave a comment

If you do not want to install any extensions or plug-ins, there is a way how you can browse your browser history faster. The history frame has the following URL: chrome://history-frame/#page=N, where N is the page number. For example, chrome://history-frame/#page=24. From here you can just try to do a binary search.

Samsung Android Phone Problems and Solution

One of the Android phones in my household (Samsung Galaxy S2) started acting chaotically. It showed signs like:

  • stopped charging;
  • showing it was connected via MTP while it wasn’t;
  • was turning on the car mode in a loop during charging;
  • when I was turning it off, it was turning on automatically;
  • when I was plugging the charger, it didn’t vibrate, etc.

The remedy was rather simple – cleanup the microUSB port using a toothbrush. Make sure your Settings/Voice input and output/Text-to-speech settings/Driving mode is unchecked.

RSS Feeds and Bloomberg (and other sites with no RSS)

June 12, 2011 18 comments

For some reason back in 2006 Bloomberg disabled its RSS feeds. So I started to follow Bloomberg less frequently. But Bloomberg offers good news. So I decided to look into this again. Bloomberg still does not offer RSS feeds, but another site does. I found Feed43 (Feed for free).

But first, a couple of words about Bloomberg. It has sites for some keywords –<keyword>. For example, (since I wanted to follow the Belarus financial crisis). It makes it easier to get news on a specific topic.

Now all you have to do is to get an RSS feed out of it. This is where Feed43 helps. It allows you to create a feed from a URL after you describe the URL so it could extract your news. It is free and you do not even have to register to use it.

Here are step by step instructions how to do this with an example:

Step 1: Specify source page address (URL)

  1. Provide a URL:
  2. Specify the encoding in necessary: <leave empty>
  3. Click “Reload”.
  4. It extracts the page contents.
  5. Please note, it removes leading and trailing spaces. This is critical to know when you configure other parameters in the next steps.

Step 2: Define extraction rules.

  1. Provide the Global Search Pattern. This is where your news block starts and ends: <h2>Belarus News</h2>{*}<ul>{%}</ul>
  2. Here the {*} indicates any character, which is used in this case to suppress spaces, {%} indicates the news block itself.
  3. Provide Item (repeatable) Search Pattern. This is the structure of your news item: <li>{*}<h3><a href=”{%}”>{%}</a></h3>{*}<p>{%}</p>{*}</li>
  4. As you can see, here the first {%} stands for the news URL, the second {%} stands for the title, and the third one stands for the news body. These variables will be converted to {%1}, {%2}, and {%3} respectively.
  5. Hit “Extract”.
  6. Now it extracts your news items.

Step 3: Define output format.

  1. RSS feed properties are easy.
  2. Feed Title (should be populated automatically): Belarus News – Bloomberg
  3. Feed Link:
  4. Feed Description: Belarus News – Bloomberg
  5. RSS item properties refer to the variables you extracted.
  6. Item Title Template (news title): {%2}
  7. Item Link Template (news link): {%1}
  8. Item Content Template (news body): {%3}
  9. Click “Preview” and you will see the extracted news.

Step 4. Get your RSS feed.

  1. Feed43 generates you an XML file with your RSS feed, which you can link to in your RSS aggregator.
  2. If you are picky, you can rename your feed.

The concept is very simple and easy to implement. The only missing thing is ability to get a publication date. But it is not always available and it requires a more complex configuration.


Dec 12, 2011 (update): It looks like Bloomberg has changed formatting. I will take a look at it with a couple of days to update the information above. But the purpose of this post was to provide some guidance, not very specific way. Stay tuned.

Dec 14, 2011 (update): One of the blog visitors suggested that this pattern should now work for the news item (step 3): <li>{*}<h3><a href=”{%}”>{%}</a></h3>{*}<p>{%}</p>{*}</li>

Dec 03, 2012 (update): I’ve got a lot of feedback recently that this no longer works. I tested it and it does work. Just use the standard double quote in #3 (Step 2). Do not just copy and paste! For some reason, WordPress tries to be too smart.

Dec 03, 2012 (update 2): Another example: Apple Technology News.

Step 1:
1. URL:

Step 2:

1. <h2>More Apple News</h2>{*}<ul>{%}</ul>

3. <li>{*}<a href=”{%}”{*}>{%}</a>{*}</li>

The rest is the same. Don’t forget there are simple double quotes in #3 above.

Categories: news, productivity, tricks Tags: , , ,

Memory Problems in Firefox on Mac. Caching Pitfalls

February 11, 2011 Leave a comment

My MacBook Pro has been having some problems – performance problems, crashes, failures to come back from sleep, etc. Often it showed the black screen while heating up. Some signs point to Firefox. Right now I have 3.6.13 running under Mac OS X 10.6.6. Since I like Firefox more than other browsers, I wanted to find a solution.

It looks like I have found one solution. This is a Firefox add-on – RAMBack. It adds a menu item “Clear Caches” under “Tools” and allows Firefox users to release some memory allocated by Firefox for some performance improvement purposes. In the Activity Monitor I have seen the reduction in “Real Memory” from 250M to 215M. Not much, but that is 14%.

Ironically, at some point allocating more memory to improve performance (by caching) slows down applications. This is not only a Firefox problem. This is a more general architectural problem. When designing an application, one should make sure that improving performance of one aspect does not negatively impacts other aspects on which the former depends on.

Another problem with Firefox on Mac is that it seems to be inefficient in handling many open tabs. Firefox on Windows can handle easily up to 150 tabs open. This is an unreachable limit for Firefox on Mac with comparable hardware configuration. Firefox on Mac starts choking with just 20 tabs.

One Way to Restore Eclipse Workspace

July 18, 2010 25 comments

My desktop got frozen and I had to restart it. After the restart I could not start Eclipse with my workspace, although it could start with newly created workspaces. I tried this (with the right link to the Restorer). Nothing worked (the Restorer did not even start). Here is the solution that worked for me. Delete “.snap” file under “C:\path\myworkspace\.metadata\.plugins\org.eclipse.core.resources” (where C:\path\myworkspace is an example of a path to the workspace) and start Eclipse with your workspace.

Note: This worked for version 3.5.2.

NetBeans 6.7.1 Updates. UML, Woodstock, and SOA for NetBeans 6.8. Solution?

April 28, 2010 19 comments

I wrote about problems getting updates for NetBeans 6.7.1. I also wrote about dropping support for UML, VisualWeb (a.k.a Woodstock), and SOA/JBI/BPEL modules in NetBeans 6.8. It looks like found a solution for both problems.

Problem 1: Unable to get beta updates for NetBeans 6.7.1 (includes VisualWeb/Woodstock, UML, SOA/JBI/BPEL, XML, Python modules and extras).

Solution: Point your “NetBeans Beta” update center from to . Please note the timestamp in the URL, hence, it may work for initial installation only. Not sure if this will work for subsequent updates.

Problem 2: NetBeans dropped support for favorite modules like VisualWeb/Woodstock, UML, SOA/JBI/BPEL.

Solution:  Point your “NetBeans Beta” update center from to . Please note the timestamp in the URL, hence, it may work for initial installation only. Not sure if this will work for subsequent updates.

Disclaimer: I have not tested these solutions yet. Please use caution.

Still no response from NetBeans.

Update (Apr 28, 2010): I got response from NetBeans about an hour after I posted this message. They are migrating the server to a new data center and right now they are using their backup servers.

Update (Apr 30, 2010): Updates are back online. The updates above are gone. On top of that I checked the UML project, and the latest commit was in January 2010. There is no guarantee that those updates would allow the UML plug-in to work in NetBeans 6.8.