Write a Comment in a JSP Page

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

14K+ Views

JSP comment marks to text or statements that the JSP container should ignore. A JSP comment is useful when you want to hide or "comment out", a part of your JSP page.Following is the syntax of the JSP comments −Following example shows the JSP Comments − A Comment Test A Test of Comments The above code will generate the following result −A Test of CommentsThere ... Read More

Insert Image into Oracle Database Using Java Program

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

6K+ Views

To hold an image in Oracle database generally blob type is used. Therefore, make sure that you have a table created with a blob datatype as:Name Null? Type ----------------------------------------- -------- ---------------------------- NAME VARCHAR2(255) IMAGE BLOBTo insert an image in to Oracle database, follow the steps given below:Step 1: Connect to the databaseYou can connect to a database using the getConnection() method of the DriverManager classConnect to the Oracle database by passing the Oracle URL which is jdbc:oracle:thin:@localhost:1521/xe (for express edition), username and password as parameters to the getConnection() method.String oracleUrl = "jdbc:oracle:thin:@localhost:1521/xe"; Connection con = DriverManager.getConnection(oracleUrl, "user_name", "password");Step 2: Create ... Read More

LocalDate lengthOfMonth Method in Java

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

128 Views

The length of the month in a particular LocalDate is obtained using the method lengthOfMonth() in the LocalDate class in Java. This method requires no parameters and it returns the length of the month in a particular LocalDate i.e. 28, 29, 30 or 31.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalDate ld = LocalDate.parse("2019-02-15"); System.out.println("The LocalDate is: " + ld); System.out.println("The length of the ... Read More

LongStream limit() Method in Java

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

97 Views

The limit() method of the LongStream class in Java returns a stream consisting of the elements of this stream, truncated to be no longer than max in length. Here, max is the parameter of the method.The syntax is as follows.LongStream limit(long max)Here, max is the number of elements the stream should be limited to.To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;Create a LongStream and add elements.LongStream longStream = LongStream.of(2000L, 35000L, 45000L, 50500L, 65000L, 72000L);Now, let’s say you only want to return 4 elements. For that, use the limit as 4.longStream.limit(4).The following is an example to implement ... Read More

Convert String to Numerical Values in MongoDB

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

636 Views

You need to use some code in order to convert a string to numerical values in MongoDB.Let us first create a collection with a document. The query to create a collection with a document is as follows:> db.convertStringToNumberDemo.insertOne({"EmployeeId":"101", "EmployeeName":"Larry"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f56528d10a061296a3c31") } > db.convertStringToNumberDemo.insertOne({"EmployeeId":"1120", "EmployeeName":"Mike"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f56648d10a061296a3c32") } > db.convertStringToNumberDemo.insertOne({"EmployeeId":"3210", "EmployeeName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f566e8d10a061296a3c33") }Display all documents from the collection with the help of find() method. The query is as follows −> db.convertStringToNumberDemo.find().pretty();The following is the output −{    "_id" ... Read More

Identify Storage Engine Used in MongoDB

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

302 Views

To know which storage engine is used in MongoDB, you can use storageEngine. The syntax is as follows −db.serverStatus().storageEngine;To know all the configuration details of storage engine, you can use the following syntax:db.serverStatus().yourStorageEngineName;Let us implement the above syntax to know which storage engine is being used in MongoDB. The query is as follows −> db.serverStatus().storageEngine;The following is the output −{    "name" : "wiredTiger",    "supportsCommittedReads" : true,    "supportsSnapshotReadConcern" : true,    "readOnly" : false,    "persistent" : true }In order to know all configuration details about the above storage engine, the query is as follows −> db.serverStatus().wiredTiger;The following ... Read More

Read Data from a Text File Using C++

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

12K+ Views

This is a C++ program to read data from a text file.Inputtpoint.txt is having initial content as “Tutorials point.”OutputTutorials point.AlgorithmBegin    Create an object newfile against the class fstream.    Call open() method to open a file “tpoint.txt” to perform write operation using object newfile.    If file is open then       Input a string “Tutorials point" in the tpoint.txt file.       Close the file object newfile using close() method.    Call open() method to open a file “tpoint.txt” to perform read operation using object newfile.    If file is open then       Declare ... Read More

Get Phone Number from Content Provider in Android

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

2K+ Views

This example demonstrate about How to get phone number from content provider 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.     In the above code, we have taken list view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.pm.PackageManager; import android.database.Cursor; import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import java.util.ArrayList; public ... Read More

Shuffle an Array in Java

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

3K+ Views

Declare a string array and add elements in the form of letters −String[] letters = { "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };Convert the above array to list −Listlist = Arrays.asList(letters);Now, create a shuffled array using the Random class object and generate the random letters with nextInt() −int len = list.size(); System.out.println("Shuffled array..."); for (int i = 0; i < letters.length; i++) {    int index = new Random().nextInt(len);    String shuffle = list.get(index);    System.out.println(shuffle); }Example Live Demoimport java.util.Arrays; import java.util.List; import java.util.Random; public class Demo {    public static void main(String[] args) {   ... Read More

Pre-Increment and Post-Increment in C/C++

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

4K+ Views

Here we will see what is the pre-increment and post-increment in C or C++. The pre-increment and post-increment both are increment operators. But they have little differences.The pre-increment operator increments the value of a variable at first, then sends the assign it to some other variable, but in the case of postincrement, it at first assign to a variable, then increase the value.Example#include using namespace std; main() {    int x, y, z;    x = 10;    y = 10;    z = ++x; //z will hold 11    cout

Advertisements