Use X-Content-Type-Options to Prevent MIME Sniffing

Ashish Jha
Updated on 18-Dec-2024 12:26:27

2K+ Views

Data security maintenance plays a critical role in online applications. MIME Sniffing is one such vulnerability, which results from improper installation of security headers and the unauthorised execution of content. A browser will try to get a resource MIME type by content rather than just the Content-Type header. A server sends that header along with a resource. This behaviour can be stopped with the help of the X-Content-Type-Options HTTP header adding to the security fortification. A developer will instruct a browser to firmly follow the defined Content-type and disallow MIME sniffing by this header. The following discussion will provide insights ... Read More

Read Data from Scanner to an Array in Java

Revathi Satya Kondra
Updated on 17-Dec-2024 23:10:17

13K+ Views

The Scanner class of the java.util package gives you methods like nextInt(), nextByte(), nextFloat(), etc., to read data from the keyboard. To read an element of an array, use these methods in a 'for' loop. Let us have a brief explanation of the methods of nextInt(), nextByte(), and nextFloat() from the Scanner class in Java. Reading Integer Data Using nextInt() Method The nextInt() method is used to read the next token from the input as an integer. It is commonly used for reading integer values from the keyboard. Example In the following example, we use the nextInt() method of the ... Read More

Difference Between PATH and CLASSPATH in Java

Revathi Satya Kondra
Updated on 17-Dec-2024 23:03:52

2K+ Views

In Java, the terms Path and ClassPath refer to different things and are used for different purposes. Let's discuss them one by one with a suitable example − Path The path environment variable is used to specify the set of directories that contains execution programs. When you try to execute a program from the command line, the operating system searches for the specified program in the current directory and, if available, executes it. In case the programs are not available in the current directory, the operating system verifies in the set of directories specified in the 'PATH' environment variable. Setting ... Read More

Floating Point Hexadecimal in Java

Revathi Satya Kondra
Updated on 17-Dec-2024 23:03:20

615 Views

In this article, we use the '%a' format specifier to represent floating-point numbers in their hexadecimal form. This is useful when you need precise control over the representation of floating-point values. For Formatter, import the following package − import java.util.Formatter; Now creating a 'Formatter'object to format the data− Formatter f = new Formatter(); Using the format() method with the %a format specifier to convert a floating-point number to its hexadecimal string.− f.format("%a", 298.45) Example 1: Basic Example In this example, we format the floating-point number '298.45' to its hexadecimal representation using the '%a' format specifier with a 'Formatter' object ... Read More

Split and Join a String in Java

AmitDiwan
Updated on 17-Dec-2024 23:02:34

5K+ Views

Splitting and join a string To split and join a string in Java, use the split() and join() method as in the below example − Example A class named 'Demo' contains the main function. Here a String object is defined and split based on the '_' value up to the last word. A 'for' loop is iterated over, and the string is split based on the '_' value. Again, the string is joined using the 'join' function, and the output is displayed. public class Demo{ public static void main(String args[]){ String ... Read More

Check Whether Product of N Numbers is Even or Odd in Python

Akshitha Mote
Updated on 17-Dec-2024 15:57:36

642 Views

In this article, we try to find different methods to solve a problem to check whether the product of n numbers is even or odd. A number that is divisible by 2 is known as an even number. otherwise; it is an odd number. For example, 14 and 12 are two even numbers, the product is 168 is an even number. 9 and 5 are two odd numbers, the product is 45 is an odd number. Consider one even number 2 and one odd number 3, product of these two numbers is 6 an even number. Facts to Check if ... Read More

Difference Between 'and' & 'is' Operator in Python

Akshitha Mote
Updated on 17-Dec-2024 14:35:04

1K+ Views

In Python, the == and is operators are used for comparison, but they serve different purposes. The == operator checks for equality of values, which means it evaluates whether the values of two objects are the same. On the other hand, the is operator checks for identity, meaning it determines whether two variables point to the same object in memory. Before discussing the differences between the == and is operators in Python, let’s first understand these operators in detail. What Is the 'is' Operator? The Python is operator tests whether two variables refer to the same object in memory. If ... Read More

Use of sprintf and sscanf Functions in C Language

Sindhura Repala
Updated on 17-Dec-2024 14:20:58

6K+ Views

The sscanf() Function The sscanf() function from the C library reads input from a string and stores the results in specified variables. Each argument must be a pointer to a variable that matches the specified type in the format string. Syntax sscanf(string, formatspecifier, &var1, &var2, ……..) Parameters The following are the parameters for the sscanf() function − The String refers to the character string to read from. The Format string refers to a character string containing the required formatting information. Var1, var2, etc., represent the individual input data items. For example, this code extracts two integers from the ... Read More

Union of Structure in C Language

Sindhura Repala
Updated on 17-Dec-2024 14:12:39

12K+ Views

In C programming, a union is a memory location shared by multiple variables of different data types. While we can define multiple members in a union, only one member can hold a value at any given time. This makes unions an efficient way to use the same memory space for different purposes. Declaration of Union Variable A union is a user-defined datatype in the C programming language. This allows the storage of different types of variables in the same location. A union can have multiple members, and only a single member can hold a value at any given time. Declaring ... Read More

Generate All Permutations of a Set in Python

SaiKrishna Tavva
Updated on 17-Dec-2024 13:06:16

5K+ Views

Permutations refer to arranging the members of a set into different sequences. if the set is already ordered, rearranging (reordering) its elements. If a set has n elements, the total number of permutations is n! (factorial of n) Some common approaches we can use to generate all permutations of a set in Python are as follows. Using a for loop Using itertools.permutations() function. ... Read More

Advertisements