Samual Sam has Published 2492 Articles

How to delete cookies with JSP?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

2K+ Views

To delete cookies is very simple. If you want to delete a cookie, then you simply need to follow these three steps −Read an already existing cookie and store it in Cookie object.Set cookie age as zero using the setMaxAge() method to delete an existing cookie.Add this cookie back into ... Read More

Java Program to generate random numbers with no duplicates

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

3K+ Views

For random numbers in Java, create a Random class object −Random randNum = new Random();Now, create a HashSet to get only the unique elements i.e. no duplicates −Setset = new LinkedHashSet();Generate random numbers with Random class nextInt −while (set.size() < 5) {    set.add(randNum.nextInt(5)+1); }Exampleimport java.util.LinkedHashSet; import java.util.Random; import java.util.Set; ... Read More

Java 8 Clock equals() Method

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

138 Views

The equality of two Java clock objects can be checked using the method equals() in the Clock Class in Java. This method requires a single parameter i.e. the object that is to be compared with the existing clock object. Also it returns true if both the clock objects are equal ... Read More

Java Tuple setAt1() method for Pair class

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

149 Views

The setAt0() method is used to set the Pair value in JavaTuples and a copy with a new value at the specified index i.e. index 1 here.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following ... Read More

How is Session Management done in JSP?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

3K+ Views

JSP makes use of the servlet provided HttpSession Interface. This interface provides a way to identify a user across.a one-page request orvisit to a website orstore information about that userBy default, JSPs have session tracking enabled and a new HttpSession object is instantiated for each new client automatically. Disabling session ... Read More

Java 8 Clock instant() method

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

160 Views

The current instant of the clock object can be obtained using the method instant() in the Clock Class in Java. This method requires no parameters and it returns the current instant of the clock object. If the instance cannot be obtained for some reason, then the DateTimeException is thrown.A program ... Read More

The contains() method of Septet class in JavaTuples

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

52 Views

The contains() method is used to search a value in Septet class.Let us first see what we need to work with JavaTuples. To work with Septet class in JavaTuples, you need to import the following package −import org.javatuples.Septet;Note − Steps to download and run JavaTuples program If you are using ... Read More

Creating alias in a MongoDB query?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

3K+ Views

You can use aggregate framework to create an alias. Let us first create a collection with documents −> db.creatingAliasDemo.insertOne({_id:101, "Name":"John Doe"}); { "acknowledged" : true, "insertedId" : 101 } > db.creatingAliasDemo.insertOne({_id:102, "Name":"David Miller"}); { "acknowledged" : true, "insertedId" : 102 } > db.creatingAliasDemo.insertOne({_id:103, "Name":"Sam Williams"}); { "acknowledged" : true, "insertedId" ... Read More

How can you delete a session data in JSP?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

874 Views

When you are done with a user's session data, you have several options −Remove a particular attribute − You can call the public void removeAttribute(String name) method to delete the value associated with the particular key.Delete the whole session − You can call the public void to invalidate() method to ... Read More

How to append data from priority queue to arraylist for listview in Android?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

121 Views

This example demonstrate about How to append data from priority queue to arraylist for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.   ... Read More

Advertisements