Monday, July 26, 2021

How to get ServletContext in Servlet, JSP, Action class and Controller? Example

How to get ServletContext in Servlet, jsp, spring controller or struts action class is common to need of any Java web developer. As ServletContext is an application-wide object and used to store variables in the global scope, getting a reference of ServletContext is pretty important. Every web application can have only one ServletContext though they can have multiple ServletConfig objects. In this article we will see :

How to get Servlet Context inside Spring MVC Controller?
How to find  Servlet Context inside Struts Action class?
How to get Servlet Context inside JSP File?
How to find Servlet Context inside HttpServlet Class?

How to loop over HashMap in JSP using JSTL? Example

Though there are a number of ways to loop over a HashMap in JSP, or any other Map implementation e.g. Hashtable, I personally prefer the JSTL foreach tag for iteration over HashMap in JSP. As a Java programmer, you will often have a strong urge to use Java code directly in JSP using scriptlet, but that's a bad coding practice and one should always avoid that. In fact, by smart use of expression language and JSTL core tag library, you can reduce a lot of Java code from your JSP page. In our last post, we have seen an example of JSTL foreach tag to loop over List, but not a HashMap, and that creates a doubt in one of my readers mind that foreach tag doesn't support Map implementation like HashMap or Hashtable as they are not Collection, but that's not true.

Difference Between ON HOLD and ON ICE Jobs in Autosys - Interview Question

Autosys is a job management and scheduling tool and widely used in Investment banks on UNIX or Linux based environments. Autosys is used to start Java process, takes backup of log files, stop Java process, cleaning and purging database, and will all sort of housekeeping jobs in Linux environment. Autosys system is made of Autosys server and Autosys clients, each server or box, which has services scheduled by autosys, requires autosys client to be installed on that. One of the key advantages of Autosys is that one job can depend upon another job, and can execute, depending upon, success and failure of parent job. Though Java developers are not asked a lot of interview questions, you might expect a few of them during your interview with Wall Street banks, Brokers or Financial institutions, which uses autosys.

How to find file and directory size in Unix with Example - Linux tutorial

How to find the size of a directory in UNIX
Finding file size or directory size in Unix and Linux is not very difficult but if you came from windows background than it may sound difficult to you because you need to remember UNIX commands for file and directory size. This is a common complaint from windows users when they exposed to Unix operating system be it Linux or Solaris. but In my opinion, having commands for doing things is more powerful because you can write powerful scripts for removing large files or taking backup of directories in UNIX which is not possible with GUI based operating systems like Windows.

Top 10 basic networking commands in linux/unix - Examples

Networking is an essential part of Unix and it offers lots of tools and commands to diagnose any networking problem. When I was working on FIX Protocol we get a lot of support queries to see whether FIX Sessions are connected or not. Since FIX Protocol uses sockets you can use the netstat, telnet, and other networking commands available in Linux for finding a problem and solve that. In this article, I will show you basic networking commands in Unix and for what purpose they are used. with the combination of grep and find command on them, you can troubleshoot most of the networking problems.

10 Examples of CUT command in UNIX and Linux

The cut command in UNIX is a nice utility program that allows you to cut data from a text file. The Linux cut command allows you to cut data by character, by field, or by column. if used correctly along with sed, find, or grep in UNIX, the cut can do lots of reporting stuff. For example, you can extract columns from a comma-separated file or a pipe or colon-delimited file using cut command. For example, if you are only interested in the first two columns you can show them using this command.  In this Linux cut command tutorial we will see different options of cut command, different examples of Linux cut command, and some important points about cut in UNIX.

Linux and UNIX Command Tutorial, Tips and Examples for Beginners

UNIX and Linux command tutorials and tips for beginners.
Hi, this is a kind of revision post where I would like to share some of my earlier posted UNIX commands tutorial. The purpose of this post is to put together all UNIX commands tutorial in one place for easy access to anyone. These are a collection of my favorite UNIX commands which you guys may find interesting. I have been working in UNIX for almost 4 years and I have learned many UNIX commands during these years which has helped me a lot during my day 2 days working on Unix shell.

10 xargs command example in Linux - Unix tutorial

xargs command in UNIX or Linux is a powerful command used in conjunction with find and grep command in UNIX to divide a big list of arguments into small list received from standard input. find and grep command produces a long list of file names and we often want to either remove them or do some operation on them but many UNIX operating system doesn't accept such a long list of argument. UNIX xargs command divide that list into sub-list with acceptable length and made it work. This Unix tutorial is in continuation of my earlier post on Unix like 10 examples of chmod command in Unix and How to update soft link in Linux. If you haven’t read those unit tutorials than check them out.

10 Examples of Date Command in Linux and UNIX

Date command in UNIX or Linux is one of the important commands to learn and master because we always need date information. no matter you want to know the current date in UNIX or your bash script needs a current date in UNIX for archiving purposes you need to use date command. In its simplest format date command shows the current date and time in UNIX while with a sophisticated option we can extract much useful information from UNIX date command. In this Unix command tutorial, we will see some useful tips on using date command in UNIX and learn more around the date in UNIX and Linux.

5 Example of kill command in UNIX and Linux

Kill command in UNIX and Linux is normally used to kill a suspended or hanging process or process group. Though kill is mainly associated with kill operation its merely a signal transporter and can send specified signals to specified processes in UNIX or UNIX like systems e.g. Linux, Solaris, or FreeBSD. Like in windows when we see a particular process hung the system we go to the task manager find the process and kill it, similarly, in UNIX and Linux we first find the process ID (PID) of the offending process and then kill it.

5 Articles to Learn about Shellshock Bash Bug

The year of 2014 is looking like a year of biggest software bug and vulnerabilities. Earlier this year, internet was bleeding by Heartbleed vulnerability and now it's shocked by ShellShock bug. To me it looks like even bigger than Heartbleed, just because it's a bug in Bash Shell, our own bash shell, most popular among all UNIX shells like C and K. Given most of the servers in Investment banks, Insurance companies, Clouds and e-commerce domain are Linux Servers with bash being most used shell, impact is quite large. I am sure people with Microsoft stack is smiling somewhere :), but wait, read the full article. First details of Shellshock bug emerged Wednesday last week, since then it has gone viral, both online and offline.

How to find IP Address from hostname in Windows Linux and Unix - Example

IP Address from hostname in Windows and Linux
How many times in a day do you have a hostname and you want to know the IP address? Hostname to IP address and IP address to hostname conversion is one of the frequent things which we need to do for many things when dealing with networking commands in Unix. For one command we need an IP address for others we need a hostname even from bash script sometimes we require a hostname and sometimes we look for an IP address.

10 Examples of tar command in UNIX and Linux

tar command in UNIX or Linux is one of the important commands which provides archiving functionality in UNIX. we can use the UNIX tar command to create compressed or uncompressed archive files by using either gzip or bzip2. In this UNIX tar command tutorial we will see examples of UNIX tar command related to basic archiving task e.g. How to create tar archive in Unix and Linux, How to extract files from tar archive in UNIX, How to view contents of tar file in Unix and Linux or how to update an existing tar file in Unix.

Sunday, July 25, 2021

List of special bash parameter used in Unix or Linux script - Example

Meaning of bash parameter used in Unix script
Many of us use a bash script for doing housekeeping and other stuff but occasionally and not much aware of special bash parameters. When I was new to the bash shell and Linux and looking for some already written bash script I used to get baffled with special bash symbols like $@, $_, $1, etc. I did know that they are bash parameter and has special meaning but I don't have all meanings of special bash parameter on top of my head and I always go to Google and search endlessly for those special bash parameter, sometimes I got and found the meaning of those special bash script parameters quickly but sometimes I need to spend some time to get what I am actually looking for, so I thought to document meanings and expansion of those special bash parameters or bash script parameters.

2 Ways to find Tomcat and Java Version in Linux and Windows - Example

You can find Tomcat and java version running on Linux either by executing the org.apache.catalina.util.ServerInfo class from catalina.jar or by executing version.sh shell script. The first solution will work on any operating system including Windows and UNIX because it's using a Java class from a catalina.jar file, which is platform-independent. Though, if you don't know how to run a class from the JAR file, you can check the steps here. Alternatively, you also have a version.bat file inside tomcat/bin directory to check the version of Tomcat in Windows.