Karthikeya Boyini has Published 2383 Articles

How can you implement hit counter to avoid loss of count data with each restart of the application in JSP?

karthikeya Boyini

karthikeya Boyini

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

243 Views

When you restart your application, i.e., web server, this will reset your application variable and your hit counter will reset to zero. To avoid this loss, consider the following points −Define a database table with a single count, let us say hitcount. Assign a zero value to it.With every hit, ... Read More

MonthDay query() method in Java

karthikeya Boyini

karthikeya Boyini

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

58 Views

The MonthDay object can be queried as required using the query method in the MonthDay class in Java. This method requires a single parameter i.e. the query to be invoked and it returns the result of the query.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import ... Read More

Delete a field and value in MongoDB?

karthikeya Boyini

karthikeya Boyini

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

386 Views

To delete a MongoDB field and value, you can use $unset operator. Let us first create a collection with documents −> db.deleteFieldDemo.insertOne({"FirstName":"John", "LastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9fb767219729fde21ddad") } > db.deleteFieldDemo.insertOne({"FirstName":"David", "LastName":"Miller"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9fb837219729fde21ddae") } > db.deleteFieldDemo.insertOne({"FirstName":"Carol", "LastName":"Taylor"}); { ... Read More

Iterate through Java Pair Tuple

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

The iteration through Pair in JavaTuples is the same as you may have seen in Java Arrays collection.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Note − Steps to download and run ... Read More

How do you implement the auto refresh in JSP?

karthikeya Boyini

karthikeya Boyini

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

328 Views

JSP makes this job easy by providing you a mechanism where you can make a webpage in such a way that it would refresh automatically after a given interval.The simplest way of refreshing a Webpage is by using the setIntHeader() method of the response object. Following is the signature of ... Read More

Duration ofDays() method in Java

karthikeya Boyini

karthikeya Boyini

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

90 Views

The duration can be obtained in a 24 hour format using the ofDays() method in the Duration class in Java. This method requires a single parameter i.e. the number of days and it returns the duration in a 24 hour format. If the capacity of the duration is exceeded, then ... Read More

The best data type to store 0, 1, null values in MySQL?

karthikeya Boyini

karthikeya Boyini

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

544 Views

You need to use tinyint(1) unsigned NULL to store the value 0, 1 and null values. The syntax is as follows −yourColumnName TINYINT(1) UNSIGNED NULL;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table StoreValue0and1orNULLDemo ... Read More

Duration get() method in Java

karthikeya Boyini

karthikeya Boyini

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

342 Views

The value of the chronological unit can be obtained using the method get() in the Duration class in Java. This method requires a single parameter i.e. the TemporalUnit for which the value is required. Also, the value of the chronological unit is returned by this method.A program that demonstrates this ... Read More

Search by property name for any document with that property in MongoDB?

karthikeya Boyini

karthikeya Boyini

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

181 Views

You can use $ne operator for this. Let us first create a collection with documents −> db.searchByPropertyName.insertOne({"FirstName":"Larry", "Age":23}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbaf7af7219729fde21ddb5") } > db.searchByPropertyName.insertOne({"FirstName":null, "Age":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbaf7b97219729fde21ddb6") } > db.searchByPropertyName.insertOne({"FirstName":"John", "Age":22}); {    "acknowledged" : true,   ... Read More

Create Triplet Tuple in Java using with() method

karthikeya Boyini

karthikeya Boyini

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

70 Views

You can also create a Triplet tuple using with() method.Let us first see what we need to work with JavaTuples. To work with Triplet class in JavaTuples, you need to import the following package −import org.javatuples.Triplet;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE ... Read More

Advertisements