Wednesday, July 31, 2013
Monday, July 29, 2013
There was time, when Sun Certification was very hot and programmer feel proud on being Sun Certified Java professional(SCJP). After Oracle took over Sun in early 2010, it changed names of all the examination from SCJP to OCPJP or OCJP, and now OCA and OCP for Java SE 7. I see there is lot of confusion among certification now days, but essentially they are of the same level at previous SCJP. Since Java gets new language feature with every new release, subsequently a new certification title is introduced. I am not agreed with upgrading your Java certification with every release, it doesn't make much sense to me, but many programmer prefer to get certified and keep it updated. By the way many Java programmers also ask me, whether doing Java certification benefits in Job search or in long term Java programming role, In short, Yes, they do. You can read my response on my post does Java Certification adds value on your career. This post is not about debating Java certification, but about preparing for them. I received lot of emails from my readers, when I wrote my post Top 5 Java Programming books, and they asked me for suggestion on how to excel on OCPJP, books and resource to prepare etc. In this post, we will see couple of good books to prepare for OCA (Oracle Certified Associate) and OCP (Oracle Certified Professional) for Java SE 7 exam. In short you can call it OCPJP 7. Apart from book, you should also use of the exam simulator, preferably from Whizlabs, which I have personally used and liked it. Whizlabs has two exam simulators for Java SE 7 exam, OCAJP 7 exam simulator and OCPJP 7 simulator, they will help you to get familiar with exam patterns and types of questions asked in actual exam.
Friday, July 26, 2013
How to bypass Websense Internet Filter at Office, School to view/access Programming and Technical blogs
Recently one of my reader emailed me that he can not access any .blogspot or .wordpress domain from his office, because websense is blocking them as personal blogs category. Since we techies, often relied on personal technical experience, tips shared by fellow developers for our work, this feels really annoying, but same time it's difficult to convince websense guys or local websense security team to not put such restriction. I was thinking about alternative and done some research on internet, which tells me that you can bypass websense filter at school or office by using proxy sites, but this idea doesn’t seems good to me, as they may contain some unwanted piece of crap, which is not good for anyone's computer. Also, if you are working for a decent size company, there is good chance that those proxy sites will also be blocked by websense. This leaves no option at all to access any technical or programming blog, hosted on free domain like .blogspot or .wordpress domain. That’s why some blogger prefer to have there own domain name than relying on blogger or WordPress.
Wednesday, July 24, 2013
Uploading File to server using Servlet and JSP is a common task in Java web application. Before coding your Servlet or JSP to handle file upload request, you need to know little bit about File upload support in HTML and HTTP protocol. If you want your user to choose files from file system and upload to server than you need to use <input type="file"/>. This will enable to choose any file form file system and upload to server. Next thing is that form method should be HTTP POST with enctype as multipart/form-data, which makes file data available in parts inside request body. Now in order to read those file parts and create a File inside Servlet can be done by using ServletOutputStream. It's better to use Apache commons FileUpload, an open source library. Apache FileUpload handles all low details of parsing HTTP request which confirm to RFC 1867 or "Form based File upload in HTML”, when you set form method post and content type as "multipart/form-data".
Tuesday, July 23, 2013
Java 1.5 introduced Thread pool in Java in form of Executor framework, which allows Java programmer to decouple submission of task to execution of task. If you are doing server side programming in Java than Thread pool is an important concept to maintain scalability, robustness and stability of system. For those, who are not familiar with thread pool in Java or concept of thread pool here is one liner, Thread pool in Java is pool of worker threads, which is ready to perform any task given to them, mostly in form of implementation of Runnable or Callable interface. Since Java supports multithreading in programming language itself, it allows multiple thread to run concurrently and perform parallel processing of task. In this article we will learn following things about thread pool in Java :
- What is Thread pool in Java?
- Why do we need Thread pool in Java ?
- What is Executor framework in Java 5?
- How to create fixed size thread pool using Executor framework in Java?
- Benefits of using Thread Pool in Java?
Thursday, July 18, 2013
Setting SSL (Secure Socket Layer) in Tomcat is often a requirement, especially while developing secure web application, which requires access over https protocol. Since Tomcat web server doesn't provide SSL settings by default, you need to know how to configure SSL in tomcat, and even worse it varies between different tomcat versions. for Example SSL setup which works on tomcat 6, doesn't work as it is in tomcat 7. In this article we will see, how to configure tomcat for https in both tomcat 6 and 7. For those programmers who are not very familiar with SSL and https here is a quick overview of SSL, certificates and https, and I suggest reading that article to get better understanding of How SSL works and How websites are accessed security over internet.
Wednesday, July 17, 2013
String in Java is very special class and most frequently used class as well. There are lot many things to learn about String in Java than any other class, and having a good knowledge of different String functionalities makes you to use it properly. Given heavy use of Java String in almost any kind of project, it become even more important to know subtle detail about String. Though I have shared lot of String related article already here in Javarevisited, this is an effort to bring some of String feature together. In this tutorial we will see some important points about Java String, which is worth remembering. You can also refer my earlier post 10 advanced Java String questions to know more about String. Though I tried to cover lot of things, there are definitely few things, which I might have missed; please let me know if you have any question or doubt on java.lang.String functionality and I will try to address them here.
Monday, July 15, 2013
Array and linked list are two fundamental data structure in programming world. Almost all programs use Array in some form or other, which makes it increasingly important to learn array and linked list. Difference between linked list and array data structure is also a popular data structure question, frequently asked in various programming job interview. This makes it even more important to learn and understand difference between an array and a linked list. Well there are lot of difference between these two starting from how they store data, to how you retrieve data from them. Main difference comes from the fact that array elements are stored in contiguous memory location, which makes it easy to retrieve them in quick time, while linked list elements are scattered through out memory, where one element knows address of other, it makes it hard to retrieve element from linked list in quick time. Some of the differences which we saw in ArrayList vs LinkedList also applicable at data structure level, because ArrayList is backed by array and LinkedList is internally backed by double linked list in Java. In this tutorial, we will learn differences between these two fundamental data structure in more details. Once you know the difference, you can make a concise choice of which data structure suits your need better. Since both of them offers distinctive advantage over others, in terms of speed and flexibility, You can make an informed choice based upon your need.
Wednesday, July 10, 2013
Making a method static in Java is an important decision . Though, static keyword is one of the fundamental concepts, many times programmers gets confused to make a particular method static or not. In Java programming, main motivation for making a method static is convenience. You can call a static method without creating any object, just by using it's class name. So if you need a method, which you want to call directly by class name, make that method static. Utility classes e.g. java.lang.Math or StringUtils, are good examples of classes, which uses static methods. Before making a method static, you should look into limitation of static methods as well, as you can not override static method in Java. By keeping these properties in mind, we can make few rules, which will help to decide when to make a method static in Java and when to use them. In this Java article, we will learn more about benefits and limitation of making a method static, and also see couple of examples of static methods from JDK to learn when and how to use static method in Java.
Monday, July 8, 2013
Thursday, July 4, 2013
Basic knowledge of SSL, HTTPS and Certificates are must for any Java programmer, especially who is working in financial and security sensitive applications, which are accessed over internet. In this article, I am giving you an overview of these three key concept and How SSL, HTTPS and certificates work together, to provide secure communication between client and server. Security is major concern while developing web application, which is accessible using HTTP protocol. Since HTTP protocol transfer data in plain text format, its not safe for transferring sensitive information like username, password, social security number (SSN) or credit card details for online shopping. HTTP protocol, also doesn't guarantee that a website, you are communicating is the one who claims i.e. if URL redirection is enable than instead of genuine website you may be routed to malicious websites and HTTP can't prevent or alert you.
Tuesday, July 2, 2013
Role based Access control using Spring Security and MVC, Mapping LDAP Groups to Authorities for Authorization
Authentication and Authorization is integral part of any Java enterprise or web application. Since most of the company uses LDAP Active directory for authentication, authorization and Role based access control (RBAC), it's good to know How to implement Role based access control using Spring MVC and Spring Security. This is the second part of my articles on using Spring Security for authentication and authorization in Spring MVC based Java application. In last part, we have learned about doing LDAP authentication against Windows active directory, and in this Spring Security tutorial, we will learn How to map LDAP groups to authorities for implementing Role based access control or authorization. If you are developing an application, whose access is controled by adding user to a particular LDAP group, then you need a mechanism to load those LDAP group after successful authentication. Spring Secuirty uses GrantedAuthority class for holding all roles for a particular user. Based upon these roles, a particular user can perform certain functionality in your application. For example, a read only user can only see data, but a user with ADMIN role, can add or remove data from your application. After implementing Role based access control, you are free of user management task, those will be taken care by respective team which manages LDAP groups and access, usually Windows support teams. In this article, we will all the steps required to map LDAP groups to granted authorities in Spring Security. If you love to read books, than you may want to check Spring Security 3.1 By Robert Winch,Peter Mularien, a great book, which teaches all good features of Spring security including LDAP authentication and authorization in great details. If you are developing secure enterprise application in Java and considering spring security, this is the one of the best and must read book on Spring Security.