Use JSP Forward Action in JSP

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

1K+ Views

The forward action terminates the action of the current page and forwards the request to another resource such as a static page, another JSP page, or a Java Servlet.Following is the syntax of the forward action −Following table lists out the required attributes associated with the forward action −Sr.No.Attribute & Description1pageShould consist of a relative URL of another resource such as a static page, another JSP page, or a Java Servlet.ExampleLet us reuse the following two files (a) date.jsp and (b) main.jsp as follows −Following is the content of the date.jsp file −Today's date: Following is the content of the ... Read More

Use Multiple Resource Bundle in Same JSP

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

351 Views

The tag is used to load a resource bundle and stores it in the named scoped variable or the bundle configuration variable.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultbasenameBase name of the resource bundle family to expose as a scoped or a configuration variableYesNonevarName of the variable to store the new bundleNoReplace defaultscopeScope of the variable to store the new bundleNoPageExample           JSTL fmt:setBundle Tag                     The above code will generate the following result −One Two Three

Find Middle Element in an Array in Android

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

144 Views

This example demonstrate about How to find middle element in a array in android.Step 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 a text view to find the middle element.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; import java.lang.reflect.Array; import java.util.LinkedList; public class MainActivity extends AppCompatActivity {    @RequiresApi(api = ... Read More

Search for a Value in Java Ennead Tuple

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

99 Views

To search for a value in Ennead Tuple in Java, use the contains() method. The value you want to search is to be set as the parameter of the method. The contains() method returns a Boolean value i.e TRUE if the value exist, else FALSE. Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package −import org.javatuples.Ennead;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External ... Read More

Make Case-Insensitive Queries on MongoDB

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

254 Views

Use regexp to make case-insensitive queries on MongoDB. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.caseInsensitiveDemo.insertOne({"UserName":"David"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f6fec8d10a061296a3c45") } > db.caseInsensitiveDemo.insertOne({"UserName":"DAVID"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f6ff28d10a061296a3c46") } > db.caseInsensitiveDemo.insertOne({"UserName":"david"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f6ffa8d10a061296a3c47") } > db.caseInsensitiveDemo.insertOne({"UserName":"Carol"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f70008d10a061296a3c48") } > db.caseInsensitiveDemo.insertOne({"UserName":"Mike"}); { "acknowledged" : true, "insertedId" : ObjectId("5c7f70058d10a061296a3c49") } > db.caseInsensitiveDemo.insertOne({"UserName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ... Read More

Combine Two Columns in a Single Column using MySQL Query

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

2K+ Views

You can use COALESCE() function for this. In the COALESCE() function, it returns the first NON NULL value from the column. To understand the concept, let us first create a demo tablemysql> create table combineTwoColumnsDemo    -> (    -> UserId int,    -> UserName varchar(20),    -> UserAge int    -> ); Query OK, 0 rows affected (1.12 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into combineTwoColumnsDemo values(101, 'John', 23); Query OK, 1 row affected (0.16 sec) mysql> insert into combineTwoColumnsDemo values(102, 'Carol', 20); Query OK, 1 row affected (0.14 ... Read More

Get Method of AbstractList Class in Java

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

174 Views

The get() method of the AbstractList class is used to get the element at the specified position in the list. It returns the element at the position set as parameter.The syntax is as follows:public abstract E get(int index)Here, index is the index of the element to return.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement get() method of the AbstractlList class in Java:Exampleimport java.util.LinkedList; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = new LinkedList();       myList.add(50);       ... Read More

Adding Navigation Bar Programmatically in iOS Using Swift

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

3K+ Views

To add navigation bar programmatically we’ll go through a series of steps that are mentioned below. We’ll be doing this in ViewWillLayoutSubviews method of our viewController.Getting the width of the current View.let width = self.view.frame.widthCreating a navigation bar with the width of our current view and height of 44 px which is the default height of a navigation bar.let navigationBar: UINavigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: width, height: 44))Adding the newly created navigation bar to our view.self.view.addSubview(navigationBar)We can further extend this example to add a title and a button to our View. The complete result should look something ... Read More

Change Collection Name in MongoDB

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

215 Views

Use use renameCollection() to change collection name in MongoDB. Following is the syntaxdb.yourOldCollectionName.renameCollection("yourNewCollectionName");Let us create a collection with documents. Following is the query> db.savingInformationDemo.insertOne({"StudentName":"Larry"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9cb44da629b87623db1b07") } > db.savingInformationDemo.insertOne({"StudentName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9cb45da629b87623db1b08") } > db.savingInformationDemo.insertOne({"StudentName":"Mike"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9cb461a629b87623db1b09") } > db.savingInformationDemo.insertOne({"StudentName":"Sam"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9cb465a629b87623db1b0a") }Following is the query to display all documents from a collection with the help of find() method> db.savingInformationDemo.find().pretty();This will produce the following output{ "_id" : ObjectId("5c9cb44da629b87623db1b07"), "StudentName" : "Larry" } { ... Read More

Drop a MySQL Table After X Hours

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

144 Views

You need to create event to drop table after x hours. The syntax is as follows −CREATE EVENT yourEventName ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL x HOUR DO DROP TABLE IF EXISTS yourTableName;Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudnetFirstName varchar(20),    StudentLastName varchar(20),    StudnetAge int ); Query OK, 0 rows affected (0.52 sec)Now implement the above event in order to drop table after 2 hours −mysql> CREATE EVENT drop_table_event_after2HoursDemo ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 HOUR DO DROP TABLE IF EXISTS DemoTable; Query OK, ... Read More

Advertisements