Posts in Category: snippets

Read Input from User

In Java, there are three different ways for reading input from the user in the command line (console).

1.Using Buffered Reader Class

This method is used by wrapping the System.in (standard input stream) in an InputStreamReader which is wrapped in a BufferedReader, we can read input from the user in the command


Get jsp response as a string inside servlet

To get jsp response as a string inside servlet is possible by wrapping the HttpServletResponse and overriding getWriter methods.

Servlet

JSP

 


Find Upper Case & Lower Case

Given a string, bellow it shows the boolean condition to find Lowercase characters, Uppercase characters.

 


Sorting HashMap by values in ascending and descending order

The below example shows Java program to sort a Map by values in ascending and descending order, you can see that it’s so easy to sort the Map.