Java Program for Matrix Multiplication

Here you will get java program for matrix multiplication. Suppose we have matrix A with number of rows and columns as m and n. Let B be a matrix with number of rows and columns as p and q. Their multiplication is possible only if number of columns of matrix A is equal to number of rows of matrix B i.e. n should be equal to p. The resultant matrix is of order mxq. Also Read: Java Program for Matrix Addition

Read more

Servlet Login and Logout Using HttpSession Example

Here you will get servlet login and logout example using HttpSession. There are various ways to maintain session but here I will use HttpSession class. In this example we have a index.html page where a login form is displayed. When user enters login details and submits the form the request is sent to LoginServlet. If the details are correct then user is redirected to HomeServlet otherwise redirected to index.html. LogoutServlet invalidates the sessions to logout the user and redirect to index.html. If anyone tries

Read more

Servlet Registration Form with MySQL Database Example

Here you will get servlet registration form with mysql database example. This simple registration form include three fields, full name, email and password. If you want you can add more fields. Servlet Registration Form with MySQL Database Example MySQL Database As here we are using mysql database so create a database with name db. Now create a table with name user having three fields fname, email and pass of varchar type. Java Project Create a dynamic web project and add following

Read more

Difference between ArrayList and Vector in Java

Here you will get to know the difference between ArrayList and Vector in Java programming language. ArrayList It is a class in Java that implements List interface. Unlike traditional array data structure, it is not fixed in length and doesn’t require its size to be specified in order to declare it. They can grow and can be reduced dynamically as per need. Apart from these benefits ArrayList class has many pre-defined methods which could help the developers save a lot

Read more

Download File From Server Using Servlet Example

Here you will get example to download file from server using servlet. The file can be of any type like image, pdf, video, music, etc. How it works? First set the content type to application/octet-stream. Now set the Content-Disposition header to attachment;filename=fileLocation. Read file from the source location using FileInputStream and write to ServletOutputStream to send as response. Also Read: Upload File to Server Using Servlet Example Download File From Server Using Servlet Example WebContent/index.html This page contains a download link.

src/com/DownloadServlet.java

Read more

Java Program for Matrix Addition

Here you will get java program for matrix addition. If you have ever done addition of two matrices in your maths subject then you can easily do this in java also. It can be done in following way. Read two matrices in 2D array a[][] and b[][] respectively inside loop. Now add each element of a[][] with corresponding position element of b[][] and save the result in c[][]. Finally display the 2D array c[][]. Note: The addition is possible only when

Read more

Upload File to Server Using Servlet Example

Here you will get example to upload file to server using servlet. File uploading is a very common and important feature of any website. In servlet it can be done in many ways. But in this tutorial I am sharing the two most commonly used methods. Also Read: Download File From Server Using Servlet Example How to Upload File to Server Using Servlet? Method 1: Servlet 3.0 If you are using Servlet 3.0 version then it provides option for uploading files

Read more

Convert Binary to Decimal in Java

Here you will get program to convert binary to decimal in Java. We can convert a binary number into decimal in two ways, using Integer.parseInt() method and by using your own logic. Below I have shared program for both the methods. Also Read: Convert Decimal to Binary in Java Convert Binary to Decimal in Java Method 1: Using Integer.parseInt() We can directly use parseInt() method of Integer class for binary to decimal conversion.

Output Enter a binary number: 11 Decimal

Read more
1 2 3 4 9