Sunday, March 17, 2024

Top 22 Apache Tomcat Interview Questions Answers for Java JEE Developers

The Apache Tomcat is one of the most popular web server used to deploy Java web application comprising HTML, JavaScript, Servlet and JSP. If you have ever worked in a Java web application you might have found yourself using Tomcat everywhere, from test environment to production. It is the defacto standard for deploying Java Web applications without EJB because using application server like WebSphere or WebLogic is both costly and superfluous for such web application. As a Java developer, working in Java and Spring based web applications, you should know some basic and advanced detail of Tomcat server to efficiently support your Java web app and troubleshoot any issue arising on request processing. 

Thursday, March 14, 2024

Top 10 HTTP Status Code Every RESTful web Service Developer Should know

A good knowledge of HTTP protocol is must for a RESTful Web Service developer because REST uses HTTP principles and a good portion of its popularity is due to HTTP itself. One of the important part of HTTP is the status code, which gives useful information related to client request. They are also known as HTTP response code because they are sent in header on HTTP response by Server to indicate what happened with client's request. The status codes ranges from 100 to 500 but not all of them are valid and useful. Instead the first number e.g. 1xx or 2xxx denotes the class of status codes. 

Saturday, March 9, 2024

10 Example of Gson in Java - JSON tutorial

The Gson library is a gift from Google to Java developers. It provides the simplest but powerful mechanism to deal with JSON documents in Java. By using Gson library, you can parse JSON String to generate Java objects, serialize a Java object to create a JSON document. You can even pretty print JSON String by setting some option to the Gson class, which is the main helper class to interact with Gson library. It also provides mechanism to deal with nulls e.g. you can include null on JSON String or you can omit them. By default Gson print JSON in compact format where null fields are not exported to JSON document but null within array and list are exported. 

Thursday, March 7, 2024

Difference between Servlet and Filter in Java

Servlet and Filter are two of the essential concepts defined in Servlet specification. They are core of any web application because most of the request will pass through them. This is why they are also very popular on Java Web developer interviews. What is the difference between a Servlet and a Filter is one of the most common and interesting interview question related to Servlet. If you can explain the difference clearly, you improve your chance of hiring a lot. In order to understand and explain the difference, you must understand what is the purpose of Servlet and Filter, How they work and how they are used in various web applications. 

Sunday, March 3, 2024

Top 27 Gson JSON Parsing Interview Questions with Answers in Java

Hello guys, parsing and creating JSON is a very common task in any Java application, particularly spring based application and that's why its important for a Java developer to not just understand the JSON format but also to be familiar with the important JSON parsing libraries in Java like Gson and Jackson. It's not just important for your day to day Java development work but also for interviews as there is a increased focus on checking if candidate is familiar with key JSON libraries like Jackson or Gson or not. Since I shared Java interview questions on core Java topics like concurrency, abstract class, static, and final modifier, a lot of my reader asked me to share JSON related interview questions as well. 

Friday, March 1, 2024

Difference between known_hosts and authorized_keys file in SSH - Linux

If you have used SSH to login into remote host in Linux, you might have come across these two files stored under the .ssh directory in your home directory e.g. ~/.ssh. Both files are used in the login process for authentication, but the main difference between known_hosts and authorized_keys files are that, known_host is used for server authentication, while authorized_keys are used for client or user authentication. SSH allows login using both password and private keys, you might have heard about trusted SSH connection between two host to download files without entering password, this is achieved using public and private keys. 

2 ways to Split String with Dot (.) in Java using Regular Expression? Examples

You can use the split() method of java.lang.String class to split a string based on the dot. Unlike comma, colon, or whitespace, a dot is not a common delimiter to join String, and that's why beginner often struggles to split a String by dot. One more reason for this struggle is the dot being a special character in the regular expression. If you want to split String on the dot you need to escape dot as \\. instead of just passing "." to the split() method. Alternatively, you can also use the regular expression [.] to split the String by a dot in Java. The dot is mostly used to get the file extension as shown in our example.

Thursday, February 29, 2024

What is the ContextLoaderListener in Spring MVC? What does it do?

The ContextLoaderListener is one of the important component of Spring MVC framework. It is like any listener defined by Servlet specification and specified in web.xml using <listener> tag. It is loaded when Spring MVC based web application is deployed in any Servlet container e.g. Tomcat. The ContextLoaderLister of Spring MVC is responsible for loading root ApplicationContext for Spring. The application context is the place where Spring bean lives. If you need reference to a Spring bean either its auto-wired or injected by framework or you can get it directly from application context. In Spring MVC based web application, there can be multiple application context e.g. root application context and context local to each DispatcherServlet.

Thursday, February 15, 2024

Review - Is Grokking the System Design interview Course on DesignGuru Worth it?

Hello guys,  we are here again today for another exciting topic to discuss. But today, we will not discuss something related to Java or any other language or spring boot. Today, we will discuss something that is immensely practical and has the potential to land you very high-paying jobs. Today we are going to review a course that focuses on System Design! System Design is crucial for coding interviews! And it's also one of the most challenging topics to master. I have shared the best System design courses for coding interviews in the past. Today, I will review one of the top system design courses for technical discussions, Grokking the System Design Interview by Design Gurus.