Uncategorized

Tokenizing/splitting string in c++

This method uses strtok to tokeninze our string given a specific delimeter, results of that are put into supplied vector. There are few other ways we can do this but this one is straight forward. #include <iostream> #include <string> #include <string.h>   #include <memory> #include <stdlib.h> #include <stdio.h> #include <list> #include <vector>   using namespace …

Tokenizing/splitting string in c++ Read More »

Proper way to read InputStream to byte array

There are many ways to accomplish this but this one does not use any external dependencies like Apache commons. Two common pitfalls that I see are that people forget to flush the ByteArrayOutputStream and they call ‘baos.write(buffer)’ instead of ‘baos.write(buffer, 0, read)’ without actually clearing the buffer, which causes the last write to append previous …

Proper way to read InputStream to byte array Read More »

Flash Scope and Flash variables in Spring MVC

Sometimes its nice to be able to transfer object between request or for flash messages without need for a whole session. Here we will use session as our store mechanism for our flash scope. This concept here can be extended into implementing a ‘Conversation Scope’ but that is a whole different animal. Example Usage @FlashAttribute(TABNAME_ATTRIB) …

Flash Scope and Flash variables in Spring MVC Read More »