Java Articles

Page 48 of 450

Provider values() method in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 194 Views

The property values in the Provider can be viewed with an unmodifiable Collection view that is obtained using the method values() in the class java.security.Provider. This method requires no parameters and it returns an unmodifiable Collection view of the property values.A program that demonstrates this is given as follows −Exampleimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) throws Exception {       try {          Signature sign = Signature.getInstance("DSA");          Provider p = sign.getProvider();          Collection val = p.values();          Iterator ...

Read More

How to write a switch statement in a JSP page?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

Following is the example of using a switch statement within a JSP page.           SWITCH...CASE Example                   The above code will generate the following result −It's Wednesday.

Read More

How to write an if-else statement in a JSP page?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 16K+ Views

The if...else block starts out as an ordinary Scriptlet, but the Scriptlet is closed at each line with HTML text included between the Scriptlet tags.Example           IF...ELSE Example                         Today is weekend                 Today is not weekend           The above code will generate the following result −Today is not weekend

Read More

How to delete cookies with JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 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 the response header.Following example will show you how to delete an existing cookie named "first_name" and when you run main.jsp JSP next time, it will return null value for first_name.Example           Reading Cookies                        Reading ...

Read More

Where will be the uploaded files stored in JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 568 Views

A JSP can be used with an HTML form tag to allow users to upload files to the server. An uploaded file can be a text file or a binary or an image file or just any document.Creating a File Upload FormLet us now understand how to create a file upload form. The following HTML code creates an uploader form. Following are the important points to be noted down −The form method attribute should be set to POST method and the GET method cannot be used.The form enctype attribute should be set to multipart/form-data.The form action attribute should be set ...

Read More

How to print date and time in specific format using JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.Let us modify the above example as follows −Example           Display Current Date & Time                        Display Current Date & Time                 Compile the above servlet once again and then call this servlet using the URL http://localhost:8080/CurrentDate. You will receive the following result −OutputDisplay Current Date & Time Mon 2010.06.21 at 10:06:44 PM GMT+04:00

Read More

Duration ZERO field in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 666 Views

The ZERO field sets the duration to zero in the Duration class in Java. This field is quite the same as the null value in different data types in Java.A program that demonstrates the ZERO field is given as follows −Exampleimport java.time.Duration; public class Demo {    public static void main(String[] args) {       Duration d = Duration.ZERO;       boolean flag = d.isZero();       System.out.println("The duration is: " + d);       if(flag)          System.out.println("The above duration is of zero length");       else          System.out.println("The ...

Read More

Instant isSupported() method in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 189 Views

It can be checked if a ChronoUnit is supported by the Instant class or not by using the isSupported() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoUnit to check. It returns true if the ChronoUnit is supported by the Instant class and false otherwise.A program that demonstrates this is given as follows −Exampleimport java.time.*; import java.time.temporal.ChronoUnit; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("The current instant is: " + i);       boolean flag = i.isSupported(ChronoUnit.SECONDS);   ...

Read More

Instant range() method in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 781 Views

The range of values for a field can be obtained using the range() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values are required and it returns the range of valid values for the ChronoField.A program that demonstrates this is given as follows −Exampleimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); ValueRange range1 = i.range(ChronoField.MILLI_OF_SECOND); ...

Read More

Instant get() method in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 271 Views

The value of the required ChronoField for an Instant can be obtained using the get() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField and it returns the value of the ChronoField that was passed as a parameter.A program that demonstrates this is given as follows −Exampleimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       int micro = i.get(ChronoField.MICRO_OF_SECOND);       System.out.println("The current Instant is: " + i);       System.out.println("The MICRO_OF_SECOND Field ...

Read More
Showing 471–480 of 4,498 articles
« Prev 1 46 47 48 49 50 450 Next »
Advertisements