As a surprise, I saw that JSPs are not capable of handling multipart form data. So, I have spent some time on figuring out how to upload a file to the server using JSP/Servlet.
There are two known libraries to use to be able to handle multipart form data; Apache Commons’ FileUpload and OReilly’s COS. I have found latter easy to use. At COS, there are two approaches to handle multipart request; push and pull model. You can either use MultipartRequest class to handle the request (push model) just like you do at a regular request (i.e. using req.getParameter()); or use MultipartParser class to do the job by iterating among request objects (pull model). Continue reading
I’ve just finished the networking part of the MuzikMekan application. Now, users are able to send friendship request to others, display them and accept or reject them. This is implemented using two database tables: Friend and FriendRequest. First table consists of user pairs who are friends in the system. If user with id=1 and id=2 are friends, Friend table include two entries as (1,2) and (2,1). This technique is used to facilitate database operations when checking friends of a user. Second table is used to keep friendship requests. If user with id=3 asks for friendship to user with id=4, an entry with columns (3,4) will be exists in the FriendRequest table.