Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Sunday, July 30, 2023

The 2024 Software Architect Roadmap

Hello guys, if you follow me or read my articles then you know that I always in search for good resources and as my experience is growing and many people in my circles are also growing, I always receive a common question, how do I transition from senior developer to Software architect? how long should I be coding? will I ever become a Software architect or solution architect? Some of these questions are born due to no growth and career stuck and some are born due to anxiety but some are also born from people who are looking to grow in their career and that's where the resource like this Software architect RoadMap can help. 

Thursday, July 27, 2023

The 2024 Flutter Developer Roadmap

Hello guys, if you want to learn Flutter, one of the popular framework for building cross-platform Mobile applications then you have come to the right place. Earlier, I have shared best Flutter courses and in this article, I am going to share complete Flutter RoadMap. If you know me, I am big fan of RoadMaps and in the past , I have shared Java Developer RoadMap, Python Developer RoadMap, Web Developer RoadMapiOS Developer RoadMap, and  DevOps Engineer RoadMap which you guys have liked it a lot. Now, we will learn about Flutter in depth. Flutter, Google's UI toolkit for building beautiful and natively compiled applications for mobile, web, and desktop, has revolutionized cross-platform app development. With its simplicity, performance, and extensive set of pre-built widgets, Flutter has become a popular choice among developers. 

10 Technical Software Developer Interview Questions Answers

Conducting an Interview is not cheap and costs both time and money to a company. It takes a lot of time to find the right candidate for a job from the 100s resume you receive from consultants and agents. They will always tell you that this guy is a Java Guru, this one is SQL Expert and the next one is the full stack developer you are looking for. If you have to trust them blindly and invite all of them for face-to-face interviews, you are going to be disappointed. One of the first things you should do is to filter candidates who claim to have certain skills like SQL but don't have them, the faster you can weed out those candidates the cheaper will be the hiring process. 

10 Examples of cURL command in UNIX and Linux

Hello guys, if you want to learn about the cURL command and looking for an awesome, hands-on tutorial then you have come to the right place. Earlier, I have shared many examples based tutorials to learn many essential Linux commands find, grep, lsof, and chmod command and in this article, I am going to share 10 examples of curl command in Linux. The curl is one of the essential commands to send HTTP requests from UNIX and Linux operating systems. curl command is part of the cURL package and it's not just useful to send HTTP requests but also allows you to transfer files using FTP and send mail using SMTP.

10 examples of grep command in UNIX and Linux

Hello guys, if you want to learn the grep command in Linux and looking for some awesome, hands-on, easy to use tutorial then you have come to the right place. Earlier, I have shared many examples based tutorials to learn essential Linux commands like find, lsof, curl, sed, and chmod command and in this article, I am going to share 10 examples of grep command in Linux. The grep command is one of the most frequently used UNIX command stands for "Global Regular Expression Print" along with find, chmod, and tar command in UNIX. grep command in Unix operating systems like Linux, Solaris, BSD, Ubuntu, or IBM AIX is used to search files for matching patterns.

Wednesday, July 26, 2023

Difference between Factory and Abstract Factory Design Pattern in Java? Example

Both the Abstract Factory and Factory design pattern are creational design pattern and use to decouple clients from creating objects they need, But there is a significant difference between Factory and Abstract Factory design patterns, Factory design pattern produces implementation of Products like Garment Factory produce different kinds of clothes, On the other hand, Abstract Factory design pattern adds another layer of abstraction over Factory Pattern and Abstract Factory implementation itself like the AbstractFactory will allow you to choose a particular Factory implementation based upon need which will then produce different kinds of products.

How to install Maven on Windows? Example

There is no difference in installing Maven on Windows7, Windows 8, Windows 8.1, or Windows 10, you can follow the same steps to install Maven in any version of the Windows operating system. Installing Maven is very easy, just download the Apache Maven ZIP file from the Apache Maven Project website (https://maven.apache.org/download.cgi). You can download the apache-maven-3.3.9-bin.zip for using Maven on your 64-bit Windows machine. Remember, Maven 3.3 requires JDK 1.7 or above to run, so make sure you already installed JDK 7 or JDK8. Once you download the binary distribution of Maven, half of the job is down.

How to Create and Initialize Anonymous Array in Java? Example

Anonymous arrays in Java is an Array without any name, just like Anonymous inner classes and policy of using Anonymous array is just create, initialize and use it, Since it doesn't have any name you can not reuse it. The anonymous array was a good way to implement variable argument methods before Java introduced varargs in Java5. You had the liberty to create an array of any length and pass that to a method that operates on an anonymous array. Classical example of such variable argument method is aggregate function like sum(), avg(), min(), max() etc.

How to Remove Duplicates from Array Without Using Java Collection API? Example

This is a coding question recently asked to one of my readers in a Java Technical interview. The question was to remove duplicates from an integer array without using any collection API classes like Set or LinkedHashSet, which can make this task trivial. In general, if you need to do this for any project work, I suggest better using the Set interface, particularly LinkedHashSet, because that also keeps the order on which elements are inserted into Set. Only from a technical interview perspective, you need to do this using either loops or recursion,  depending upon what is your strongest area. In this article, I am sharing a naive solution, which has lots of limitations to be considered as production quality code, It's not the best solution but still a solution.

Why use Log4j logging vs System.out.println in Java? Answer

Printing messages to the console is an integral part of the development, testing, and debugging of a Java program. If you are working on a Server-side application, where you can not see what's going on inside the server, your only visibility tool is a log file; without logs, you can not do any debugging or see what's going on inside your application. Though, Java has a pretty handy System.out.println() method to print something on the console, which can also be routed to log file but not sufficient for a real-world Java application. 

Difference between float and double variable in Java? Example

Though both float and double datatype are used to represent floating-point numbers in Java, a double data type is more precise than float. A double variable can provide precision up to 15 to 16 decimal points as compared to float precision of 6 to 7 decimal digits. Another significant difference between float and double is their storage requirement, double is more expensive than float. It takes 8 bytes to store a variable while float just takes 4 bytes. This means if memory is a constraint then it's better to use float than double. By the way, the double type also has a larger range than float and if your numbers don't fit well in float then you have to use double in Java.

3 Examples to Generate Random Alphanumeric String in Java - UUID Example

Many times we need random alphanumeric String for one or another purpose and Thankfully Java provides a couple of ways to create random Strings which can be numeric, alphanumeric, or simply alphabetic. If you are familiar with Java API to generate random numbers like java.util.Random class and Math.random() method than It's quite easy to create an array with choice of characters like Alphanumeric, numeric, alphabets, special characters, and choose random characters to construct random String. If you like using an open-source library and happen to be using Apache commons-lang then generating an alphanumeric String is just one line of code as shown in the first example in our Java program. 

Saturday, July 22, 2023

How to fix "Error starting ApplicationContext" in Spring Boot? [Solution]

Hello guys, earlier, I shared how to solve creating bean error in Spring Boot and today, I am going to explain how to  deal with error related to started Application Context. Spring Boot is a popular framework for building Java applications, providing a streamlined development experience. However, like any software, Spring Boot applications can encounter errors during startup. One common error that developers may encounter is the "Error starting ApplicationContext" error. This error typically indicates an issue with the application's configuration or dependencies. In this article, we will explore various solutions to fix this error and ensure a successful startup of your Spring Boot application.

Friday, July 21, 2023

Difference between Oracle SQL Query vs Microsoft SQL Server or Sybase? Answer

Oracle and Microsoft SQL Server are two of the most popular database but they are very different from each other and if you are migrating SQL queries or databases, tables from Oracle database to Microsoft SQL Server 2008 then you are bound to face some issues. The main reason for these porting issues are features that are supported and exists in the Oracle database, but not available in Microsoft SQL Server 2008 like SEQUENCE, Order by clause in subqueries, and derived tables, derived table without a name, etc. I am sure there are a few more and they will surface based upon different database objects you are using in your tables and queries.

4 Best practices to name your JAR file in Java

If you are an author of an internal, proprietary Java library or an external open-source library,  or you are one of those lucky developers who ship Java applications by yourself then you should follow these best practices while naming your JAR files. These best practices are a result of the practical experience of using hundreds of Java libraries and applications. Following these best practices will help in better management of JAR files. It's part of my other best practices articles like best practices while naming a variable, writing comments, overriding methods, multi-threading, JDBC, and best practices while dealing with passwords. If you are interested in learning more about best practices, you should read those articles.

Avoid Using "==" instead of equals() to compare Objects in Java? Example

In this part of Java programming mistakes, we will take a look at another common pattern, where programmers tend to use the "==" operator to compare Objects, similar to comparing primitives. Since the equality of objects can be very different in the physical and logical sense, and in the case of domain objects, it's mostly driven by business rules, comparing objects with the "==" operator, introduces subtle bugs, which are hard to find. The difference between equals() and == operator,  one of the Java classics is also asked to find out if the developer is familiar with this important concept or not.

How foreach or Enhanced for loop works in Java? Example

It's a long time since JDK 1.5 introduced the enhanced for loop, almost 12 years ago in the year 2004, but still, many Java developers don't know the basics of enhanced for loop, also known as for each loop in Java. The enhanced loop provides the cleanest way to loop through an array or collection in Java, as you don't need to keep track of the counter or you don't need to call the hasNext() method to check whether there are more elements left. The key point, which many Java developer doesn't know about the enhanced for loop is that you can use any Object which implements the Iterable interface on for (: ) construct, you can even use enhanced for loop to loop through the array.

Thursday, July 20, 2023

A Better way to write Complex SQL queries for Programmers

There is no doubt that writing code is more art than science, every coder cannot write beautiful code which is both readable and maintainable, even with experience. In general, coding improves with experience when you learn the art of coding e.g. favoring composition over inheritance or coding for interface than implementation, but only a few developers able to master these techniques.  The same applies to SQL queries. The way you structure your query, the way you write it goes a long way to communicate your intent to the fellow developer. When I see SQL queries on emails from multiple developers, I can see the stark difference in their writing style.

Monday, July 17, 2023

5 Tips for Running SQL Queries on Production Database

Did you ever face a situation where some of your innocuous-looking action has caused production issues and that too big time? Well, I hope you have not because it's certainly, not a pleasant experience. One such innocuous-looking action is running SQL queries on production databases. I had that in the past very early in my career where I removed some config as duplicates only to find after a week that it stopped publishing messages to one of the downstream. When you work in complex systems that have so many components, millions of lines of code, thousands of configurations, and many databases with hundreds of tables, you have to be really careful with anything you do.

Friday, July 14, 2023

How to find duplicate records in a table on database - SQL tips

How to find duplicate records in a table is a popular SQL interview questions which have been asked as many times as difference between truncate and delete in SQL or finding second highest salary of employee. Both of these SQL queries are must know for any one who is appearing on any programming an interview where some questions on database and SQL are expected. In order to find duplicate records in the database table you need to confirm the definition of duplicates, for example in below contact table which is suppose to store name and phone number of the contact, a record is considered to be duplicate if both name and phone number is the same but unique if either of them varies.

Thursday, July 13, 2023

How to find second highest or maximum salary of Employee in SQL - Interview question

How to find the second highest or second maximum salary of an Employee is one of the most frequently asked SQL interview questions similar to finding duplicate records in table and when to use truncate vs delete. There are many ways to find second highest salary based upon which database you are using as different database provides different feature which can be used to find the second maximum or Nth maximum salary of employee. Well this question can also be generalized with other scenario like finding second maximum age etc. In this SQL tutorial we will see different example of SELECT SQL query to find second highest salary independent of databases or you may call in ANSI SQL and other SQL queries which uses database specific feature to find second maximum salary.

SQL query to copy, duplicate or backup table in MySQL, Oracle and PostgreSQL database - SELECT * Example

Many times we need to create backup or copy of tables in databases like MySQL, Oracle, or PostgreSQL while modifying table schema like adding new columns, modifying columns, or dropping columns. Since it's always best to have a backup of a table that can be used in any event. I was looking for an easy way to create an exact copy or duplicate tables which must be the same in the schema as well as in data, similar to creating a copy of the folder. Luckily there is an easy SQL query "CREATE table table_name AS" which allows you to create an exact copy of the table by executing just one SQL query. Yes, you read it correctly, no tool is required to create a backup of the table you just need to execute an SQL query.

Wednesday, July 12, 2023

How to use or enable Spring Security in Java Web application?

Spring Security is one of the most popular open-source frameworks to implement security in Java web applications in a declarative way. It provides several essential security features like LDAP authentication, authorization, role-based access control,  remembers the password, URL protection, concurrent active sessions management, etc. To enable Spring security in Java Web application, you need to configure three things -  declare a delegating proxy filter in web.xml, add the ContextLoaderListener in web.xml and provide actual security constraints on applicationContext-Security.xml file. Since Spring security uses a chain of filters to implement various security constraints, also known as Spring's "security chain filter", it relies on web container for the initialization of delegating filter proxy.

Saturday, July 8, 2023

Apach FreeMarker HelloWorld Tutorial and Example in Java

Apache FreeMarker is a free, open source, Java based template engine which allow you to create dynamic content by combining the static template with dynamic data. The template is written in their own proprietary language called FTL(FreeMarker Template language), which is like any scripting language which allows you to insert variables, looping constructs and conditional logic. FreeMarker is often used with JSP in MVC based Java application to generate dynamic content but it's not limited to Servlet or JSP and you can use with core Java as well. In fact, this FreeMarker Hello World Example is without JSP. We generate a dynamic HTML file by using Freemarker in the main() method itself. Apache FreeMarker is often used for generating source code, configuration files or personalised e-mails.

What are Idempotent and Safe methods of HTTP and REST [Interview Question]

If you are learning REST and want to understand the difference between the Idempotent and safe method then you have come to the right place. Earlier, I have shared the best books and courses to learn RESTful Web services and in this article, I will answer this popular REST Interview question. In order to efficiently work with REST and RESTful web service, good knowledge of HTTP is really helpful. Even though REST seems easy, designing a uniform and consistent RESTful API is a tough job. One of the tricky tasks is choosing right the HTTP method for the right job like when to use PUT vs POST. Once you know the meaning and purpose of different HTTP methods, it helps to choose the right method for the right job.

How to Create Restful Web Services in Java using Jersey [Hello World Example]

Along with Spring Boot, Apache CXF, and  Restlet, Jersey is another popular open-source framework to create RESTful web services in Java. Jersey conforms to JAX-RS specification and actually it is the reference implementation of JAX-RS (JSR 311)(http://jsr311.java.net/nonav/releases/1.1/index.html) specification. In the last article, we have seen the Restlet HelloWorld Example and today we'll see the Jersey HelloWorld Example. Typically, when a developer thinks of creating a RESTful web service using Java, they assume that using a Java EE application server is the only way to create this type of application.

Google Protocol Buffers (ProtoBuf) - Best Alternative to Java Serialization

If you have done some serialization works in Java, then you know that it's not that easy. Since the default serialization mechanism is not efficient and has a host of problems, see Effective Java Item 74 to 78, it's really not a good choice to persist Java object in production. Though many of the efficiency shortcomings of default Serialization can be mitigated by using a custom serialized format, they have their own encoding and parsing overhead. Google protocol buffers, popularly known as protobuf is an alternate and faster way to serialize Java objects. It's probably the best alternative to Java serialization and useful for both data storage and data transfer over the network.

Top 10 Multithreading and Concurrency Best Practices for Experienced Java Developers

Writing concurrent code is hard and testing correctness with concurrency is even harder. Though Java programming language provides lots of synchronization and concurrency support from language to API level, it eventually comes to an individual's diligence and expertise to write bug-free Java concurrency code. These Java concurrency and multi-threading best practices are a collection of some well-known tips, which help you to write better concurrency code in Java. Some of you may be familiar with these tips but it's often worth revising them time and time again. 

Introduction of How Android Works for Java Programmers

Android development is a popular buzz in the Java programming world. It's Android, which keeps Java at the forefront of the last couple of years. Now, How important is it to understand or learn Android for Java programmers? Well, it depends on, if you like application development and wants to reach a mass, Android offers that opportunity to you. Millions of Android phones are available and they keep increasing, with pace, much higher than iPhone or iOS. What all this means is, it does make a lot of sense to learn Android programming for Java programmers, and this article is about that, but this is also one of the good reasons to learn Java programming. This tutorial will give you a basic idea of How Android works? not detailed but a good overview.

Friday, July 7, 2023

Difference between notify and notifyAll in Java - When and How to use

notify vs notifyAll in Java
What is the difference between notify and notifyAll method is one of the tricky Java questions, which is easy to answer but once the Interviewer asks follow-up questions, you either got confused or not able to provide clear-cut and to the point answers? The main difference between notify and notifyAll is that the notify method will only notify one Thread and the notifyAll method will notify all Threads which are waiting on that monitor or lock. By the way, this is something you have been reading all over places and to be frank,  this statement despite being correct is not complete, and it's very difficult to understand the difference between notify vs notifyAll by just reading this statement.

Thursday, July 6, 2023

Differences between gRPC, REST, SOAP, and GraphQL

There is no doubt that today's word is about API. No matter what kind of application you are working it involves API whether its internal API to get data from another system or external API like Paypal and Stripe API for payments, but how do you incorporate APIS in your system. In the vast landscape of API technologies, there are four prominent contenders that stand out: gRPC, REST, SOAP, and GraphQL. Each of them offers a unique approach to building and consuming APIs, presenting developers with a plethora of choices. In this article, we will delve into the distinctive characteristics of gRPC, REST, SOAP, and GraphQL, unraveling their differences and helping you navigate the API universe with confidence.

Monday, July 3, 2023

How to enable HTTP Basic Authentication in Spring Security using Java and XML Configuration? Example Tutorial

In the last article, I have shown you how to enable Spring security in Java application and today we'll talk about how to enable Basic HTTP authentication in your Java web application using Spring Security. I'll show you how to do that using both the Java configuration and XML configuration if you are using Spring Security 3.1 or lower version, but before that let's understand what is Http basic authentication and why do you need that? One of the most common ways to authenticate a user in a web application is by using a form login like you provide a login page and the user will enter his username and password for authentication. This works great for human users but sometimes there are situations where you can't use a login form for authentication.

What is SecurityContext and SecurityContextHolder in Spring Security? Example Tutorial

The SecurityContext and SecurityContextHolder are two fundamental classes of Spring Security. The SecurityContext is used to store the details of the currently authenticated user, also known as a principle. So, if you have to get the username or any other user details, you need to get this SecurityContext first. The SecurityContextHolder is a helper class, which provides access to the security context. By default, it uses a ThreadLocal object to store security context, which means that the security context is always available to methods in the same thread of execution, even if you don't pass the SecurityContext object around. Don't worry about the ThreadLocal memory leak in web application though, Spring Security takes care of cleaning ThreadLocal.

How to delete or remove rows from table using JOINs in SQL Server? Example Tutorial

Hello guys, there are often a scenario where you need to delete data from a table by using joins. For example, you want to delete all employes who are also manager in this case, you need to self join with the table to find all the employees who are manager and then you need to delete them. Similarly, if you need to delete all employees who are not assigned any department then you need to use left or right out join to find them and then delete it. Bottom line is that It's a little bit tricky to delete from a table while using any type of JOIN in SQL like Inner Join, Left Outer Join, or Right Outer Join. The obvious syntax doesn't work as shown below:

Difference between a Thread and an Executor in Java

Even though both Thread and Executor, both are used to execute some code in parallel, there are some key differences between them. The main difference between a Thread and an Executor in Java is that it later provides a thread pool in Java. Along with several concurrency utilities like CountDownLatch, CyclicBarrier, Semaphore, FutureTask, Callable interface, and Conditions, JDK 5 also introduced a built-in thread pool, which provides a set of working threads to run your code in parallel. Since creating, starting, and running a thread is a time-consuming and expensive operation, many Java applications create a spool of thread at start-up and leverage that for executing the task in parallel until Java introduced the built-in thread pool.

Can You Make an Array or ArrayList Volatile in Java?

This is one of the many interesting multi-threading questions I have shared in my post 50 multi-threading interview questions. Yes, you can make an array volatile in Java, there is no problem with that, neither compiler will flag any error not JVM will throw any exception but the tricky part is why you want to make an array volatile and what is the effect of making an array volatile in Java? In order to answer this question, you must be familiar with both volatile modifier and Java memory model, otherwise, it would be difficult to answer, and that's why it's also one of the trick questions from Java interviews. Before answering this question in detail, let's first revise what is a volatile keyword in Java and what kind of guarantee it provides in the context of multithreading and concurrency.

How to setup JNDI Database Connection pool in Tomcat - Spring Tutorial Example

Setting the JNDI Database Connection pool in Spring and Tomcat is pretty easy. Tomcat server documentation gives enough information on how to set up a connection pool in Tomcat 5, 6, 7, 8, or 9. Here we will use Tomcat 7 along with the spring framework for creating a connection pool in the Tomcat server and accessing them in Spring using JNDI code. In our last article, we have seen how to set up a database connection pool in Spring for a core Java application that doesn't run on a web server or application server and doesn't have a managed Java EE container.

How to create PDF File in Java - iText Example

Hello guys, generating PDF files in today’s enterprise applications is quite common. Doing this with Java is not an easy task as Java does not gives default api’s to handle PDF files. No worries, iText jar is for you. Earlier, I have shared about iText vs Apache FOP, two of the most popular libraries to create PDF files and today, I will show you an example of how to create a PDF files using the iText library in Java. If you are not familiar,  iText is a free Java-PDF library that allows you to generate PDF files on the fly (dynamically). iText is an ideal library for developers looking to enhance web- and other applications with dynamic PDF document generation and/or manipulation.

How to add new columns to an existing table in SQL Server database? Example tutorial

Hello guys, adding a new column to an existing table with data is always tricky and if you don't pay enough due diligence then you risk of corrupting or deleting existing data. You need to know what data is there, how much data is there, to gauge how long your query is gonna take to complete in production. Also, you cannot add NOT NULL columns into an existing table if they are not empty and you don't have a default value specified. If you know SQL then you probably know that you can add columns to an existing table in SQL Server using the ALTER command. It not only allows you to add a column but to drop columns as well.

How to dynamically create a div in jQuery? Example

Many times you need to create an HTML element and dynamically add that into DOM without reloading the page. The traditional way of doing this is by using JavaScript's innerHtml() function but jQuery provides better ways to achieve the same effect. You can use jQuery DOM manipulation methods like append(), appendTo() or html() to add new HTML elements like div, paragraph, headings, image into DOM without reloading the page again. In this tutorial, I will show you how to dynamically create a div and add that into a page by using pure jQuery.

Binary Tree PreOrder Traversal in Java - Recursion and Iteration Example

Unlike a linked list and array which are linear data structure and can only be traversed linearly, there are several ways to traverse a binary tree because of its hierarchical nature. The tree traversal algorithms are mainly divided into two types, the depth-first algorithms, and breadth-first algorithms. As their name suggests, in a depth-first algorithm, the tree is traversed downwards (towards the depth) before the next sibling is visited, the Pre Order, InOrder and PostOrder traversal of a binary tree is actually depth-first traversal algorithms. On the breadth-first algorithm, also known as level order traversal, the entire breadth of the tree is traversed before moving to the next level, hence it is also known as level order traversal.

How to convert Result of SELECT Command to Comma Separated String in SQL Server? Example

Sometimes, you need the result of the SQL SELECT clause as a comma-separated String e.g. if you are outputting ids of white-listed products. By default, the SELECT command will print each row in one line and you get a column of names or ids. If you need a comma-separated String then you probably need to use a text editor like Notepad++, Edit Plus, or a tool like Microsoft Excel to convert that column of values into a big CSV String. I often use a text editor like editplus to replace the \n to comma (,) to create such CSV string because it supports regular expression-based find and replaces operation.

What is Strangler Pattern in Microservices? How to use it?

As organizations embrace the microservices architecture style, the need to modernize legacy systems and seamlessly transition to microservices becomes crucial. However, undertaking a complete system overhaul can be daunting and risky. This is where the Strangler Pattern comes into play. The Strangler Pattern offers a structured approach to incrementally transform monolithic applications into a more flexible and scalable microservices architecture. In the past, we have understood about  Database Per MicroservicesCQRSEvent SourcingBackend for Frontend, and Circuit-breaker pattern and in this article, we will explore what the Strangler Pattern entails and how to effectively employ it to ensure a successful migration.

Sunday, July 2, 2023

How to create and call stored procedure in MySQL with IN and OUT parameters? Example Tutorial

It's hard to remember the exact syntax of, how to create a stored procedure in MySQL until you are creating and working on stored procedure frequently, simply because the syntax is not a one-liner. You need to remember the exact syntax if you are using the MySQL database from the command line. What help, in this case, is, quick examples. In the last couple of MySQL tutorial we have seen How to find the second highest salary and How to join 3 tables in one query; In this MySQL tutorial we will see a couple of examples of creating stored procedure and calling stored procedure using IN and OUT parameters. A

Difference between application/x-www-form-urlencoded and multipart/form-data in HTTP/HTML?

Recently in one of the Java web developer interview, one of my readers asked about the difference between x-www-form-url-encoded and multipart/form-data MIME types. In HTTP, there are two ways to send the HTML form data to the server either by using ContentType application/x-www-form-urlencoded or by using multipart/form-data. Even though both can be used to send both text and binary data to the server there is a subtle difference between them. In the case of x-www-form-urlencoded, the whole form data is sent as a long query string.

How to find Length of String in SQL Server? LEN() Function Example

One of the most common task while writing SQL queries or stored procedure is to find the length of String. Since most of the columns are VARCHAR, you often need to find the length before taking any action. In Java, you can find the length of String by using the length() method but how about SQL Server? How will you find the length of String in Microsoft SQL Server in general and Microsoft SQL Server 2016 in particular? Well, you can use the LEN() function to find the length of a String value in SQL Server, for example, LEN(emp_name) will give you the length of values stored in the column emp_name. This method exists from SQL Server 2008 onwards which means you can use this function in SQL Server 2012, 2014, 2016 and latest version of Microsoft SQL Server i.e. SQL Server 2017.

How to read and write Images in java using ImageIO Utility

Writing an Image file in Java is very common scenario and in this article we will see a new way to write images into file in Java. javax.imageio.ImageIO is a utility class which provides lots of utility method related to images processing in Java. Most common of them is reading form image file and writing images to file in java. You can write any of .jpg, .png, .bmp or .gif images to file in Java. Just like writing, reading is also seamless with ImageIO and you can read BufferedImage directly from URL.

Maven JAR Artifiact Dependency Search Not Working in Eclipse - Solved

Recently I face a strange issue while using Maven in Eclipse via M2Eclipse plugin. I have created a Maven Java project in Eclipse and subsequently tried to add Spring framework as a dependency, to my surprise, nothing was happening. Eclipse was not able to search dependency in Maven central repository. I was surprised because I have never faced this issue while I was using the M2Eclipse plugin for a long time. After some trial and error, I realized that this is my brand new workspace and I am running with Eclipse Luna, the newest version of Eclipse which I had just downloaded a couple days of the back. My first hunch was that Eclipse might not able to connect to the Internet, and to verify that I tried connecting the Eclipse market place, and boom it was working fine.

How to enable/disable an element using jQuery and JavaScript? Example

Sometimes we need to enable and disable input elements like text box, radio buttons, or checkboxes, but every time you make a change you need to reload the HTML? The question is, how can we do it dynamically without loading the page? Well, we can use JavaScript, particularly jQuery to do this. An element can be disabled in HTML by setting disable property to true and enabled again by setting disabled=false. By using jQuery, you can grab the element you want to enable or disable and change this property by using the prop() or attr() function, depending upon the version of jQuery you are using.

Saturday, July 1, 2023

What is Abstract Class and Method in Java? Examples and Frequently asked Questions

Both abstract class and abstract methods are very important concepts in core Java and every Java developer should have good understanding of what they are, when to use them and how to use them. They are also very popular on core Java job interviews as well as on Oracle Java certifications e.g. OCAJP or OCPJP.  You will often find a lot of code based questions testing essential core Java concepts based upon abstract class and methods in the real exam. All good mock exam simulators e.g. Whizlabs and Certification-questions also contains a lot of questions testing and explaining these key concepts, which shows how important they are for Java developers. 

How To Use The JSON Web Token (JWT) In Spring Boot And Spring Security Project

Hello guys, In the world of web application security, JSON Web Tokens (JWTs) have gained significant popularity. JWTs provide a secure and efficient way to handle authentication and authorization in modern web applications. In this article, we'll explore the ins and outs of using JWT in a Spring Boot and Spring Security project. From generating tokens to verifying and handling them, we'll cover everything you need to know to leverage JWT effectively in your applications.