Monday, September 13, 2021

thumbnail

502 Bad Gateway: The proxy server received an invalid response from an upstream server

 Hi All, 

 I have gone through this error and we resolved this error after a week along with my team. we invested time to debug, validating all possible possibles. after our effort, we resolved this error. this error is not found in the local or testing environment. in our case this issue is found in the production environment.

  we are thought 502 error, it will be resolved after sometimes automatically but bad luck it is not happening in my case. so I started R&D for this issue. in a journey of R&D, I am sharing with guys. it will help to resolve this error as easily as possible. 

the first clarification is 502 is a server error, not your codebase so immediately don't touch your code.

* check your IIS server and ARR ( Application Request Routing )

* configure your proxy setting for Application Request Routing 

* Increase  ARR ( Application Request Routing ) time out from 120 sec to max (in my case max is 3000 sec )

Please refer  for Proxy :

https://success.outsystems.com/Support/Enterprise_Customers/Troubleshooting/Troubleshooting_HTTP_502_(bad_gateway)_errors


Special thanks to my team for resolve this issue :)






Wednesday, April 7, 2021

thumbnail

How to take string user input using scanner

 In our Daily code life, String is playing a vital role. In this blog, we will discuss taking string value input from users. The user can give any string input. Our goal should be code should work and it should give the desired output. 

  Scanner class having one method next line(). This method job is taking input string value from the console. Before seeing.

 In the previous blog, I posted how to take int value from users. You can check it out. 

next() method and nextLine() method is using most of time. we will see first what is next() method and how to use it by one code bit example. One more thing when to use next() and next Line(). we will discuss.

"When you feeling like stopping think about why you started. "

next() method is used for taking input till space. it can't read input separated by space. The next line() method is used for reading input separated by space. this is a main difference between next() and  next Line() .

if you want to read only one word you can use the next() method. 

more than one word like one sentence or line better to go next Line() method.

Sometimes you don't know what user gives input so my recommendation is to always use the next Line() for the safer side. While interview time, you always write your code by taking user input. it will help to save your time changing input. the interview would be impressed about the way of your writing code. 

Let's see the below code you will get to know how to use it in code. 

Steps  : 

// Create Object of Scanner 

// Inform the user for input 

// hold the input in one string variable 

// display the result 


Code Bit : 

import java.util.Scanner;


public class ExampleScannerInput {


public static void main(String[] args) {

// Create Object of Scanner

Scanner sc = new Scanner(System.in);

// Inform the user for input

System.out.println("Enter a input : ");

// hold the input in one string variable

String input = sc.next();

// display the result

System.out.println("The result is :" + input);

}

}

Screenshot image : 

next() method


Result :

next() method in java


                               we saw the next() method code. I have one question if I gave two words separated by space means it will throw an error. Cool yar it will not throw an error. it will print only one word till space. after space, it will not print. That is the next() method specialty. if have curious once try let me know in the comment box. let's go we will see the next Line() method.

Code bit :

import java.util.Scanner;


public class exampleScannerNextLine {


public static void main(String[] args) {

// Create Object of Scanner

Scanner sc = new Scanner(System.in);

// Inform the user for input

System.out.println("Enter a input : ");

// hold the input in one string variable

String input = sc.nextLine();

// display the result

System.out.println("The result is :" + input);


}


}

Screenshot images:


nextLine() method in java

 





Result : 

nextLine method in java





Learned things  :

  • next line() method: it is used to read user input line or sentence. 
  • next() method: it is used for reading words until space.
 
Contribute:  
  • Regarding Job Details Post 
  • Referral Jobs Details
  • Opening for Freshers 
  • Knowledge share with us
Send mail to lifeofsrg@gmail.com. will publish with your name and your content.
 Learn, practice, and share knowledge 

                                                                                                             Thank you :)
                 
                                                                                                      



Tuesday, April 6, 2021

thumbnail

why we need to take user input using scanner

                    Most of time we need to take input from users. why we need to take input from user. is it important ? Yes , it is important because I will explain by one example . let me allow,

           we will write one simple program adding a two numbers. Two numbers are input for  code.  please refer below code snippet. we did hard code like a = 10 and b = 20,  

                  suddenly we need to change means input value. Again go to code and change the variable value. it seems easy for one or two times. n times need to change. it is very difficult to do. So we will take input from user .  user can give any input . code should be work and it should give correct output. That sounds good. so we will use scanner class .

  Code bit : Add two number in Java

Add Two Number in Java
Result






 Scanner class will help us to take input from user. it is present in Javautil  package. 

Let's see code 

In the code, we will take two integer number by user Using Scanner 

Steps :

  • Create scanner object 
  • Take first number  from user (Console) using scanner 
  • Take second number from user (Console)
  • Additional logic 
  • Display the result 


Scanner in Java

import java.util.Scanner;

public class ExampleScanner {

public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   // Taking number from User
       System.out.println("Enter first number : " );
         int a =  sc.nextInt();
       // Taking number from User
       System.out.println("Enter second number : " );
         int b =  sc.nextInt();
        // Adding 
        int c = a + b;
        // Printing number
        System.out.println("The result is :"+ c);
        }
}


Result :



Leant Things : 
  • Scanner Object - it is used for taking user input. 
  • we need to import scanner from java.util.Scanner;
  • Creating scanner object like  Scanner sc = new Scanner(System.in);
  • nextInt() - this method is used for taking int type values from user
we learn only taking int value from user.  we will see upcoming blogs other codes snippet which will take float, double, etc datatypes and string as input  using scanner.



                                      Thank You :)

Sagar R G     
Java Developer 



Thursday, March 11, 2021

thumbnail

Write a Java program to get the character at the given index within the String.

we can learn to get the character at the given index within the String

Approach Steps 🤔

    • Take given original string 
    • Print  original string for reference 
    • use the charAt() method to find out a character at a given index i.e original.charAt(1);
    • hold it by int type 
    •  while display time typecast int to char 
    • print out the result on the console.

Code bit :


interview Code

Practice Code in LeetCode PlayGround 🥇🥇🥇🥇

Source code :

public class MainClass {
    public static void main(String[] args) throws IOException {
        // take a Given string 
        String original = "Java Code Practice";
        // Print  original string for reference 
       System.out.println( "Given original string :--"+ original+"\n");
        // chatAt method : it is used for find out character at given index
        // hold it by int type 
        int givenIndex = original.charAt(1);
        // while display time type cast to char 
        // Print the character at given index
        System.out.println( "the character at zero index :-- "+(char)givenIndex);
    }
}



Result : 

Result string code


Learnt from this Code Bit :

  • charAt() method: this method is used for getting a character at a given index from the original string. for the above example gave an index at 1 in charAt(1)  method so got the result "a".
  • One more thing "\n" used for the next line 
  • type casting is done int to char so got it from the above code bit. 


Thank you!

:)Sagar R G
 


thumbnail

List Of Most Important Java Program Topics

will discuss in this post, the java program some important topics.

Java_Logo

the list is very useful while interview time because the questions will ask frequently. 

In my interview time, the companies are asked most of the question are below list.  I think it will help beginners who are trying to get jobs as fresher. Ok,  my interview time 80 percentage questions were asked by String coding questions, Oops concepts explanation, exception handling, Java JDBC, collection and DSA (Data structure and Algorithms). 

In this article, we can see 

 List Of Most Important Java Program Topics/Concepts For Beginners

    •  Data Type 
    •  Operators
    • Control statement
    • Selection statements
    •  Oops concepts
    • Java String 
    • method overload
    • method overriding 
    • Interface
    • Abstract
    • Access modifier
    • Java I/O concept
    • collection
    • Exception handling 
    • Java JDBC
    • Java Date
    • Polymorphism
    • Java Array
    • Java Reflection 
    • Java Regex
This is the list of very important concepts in the core java. apart from other topics are there for learning in-depth java. but I focused on the beginners level learner and job seekers as freshers.

Thank You 

Sunday, August 2, 2020

thumbnail

Java program to demonstrate working of java.lang.Math.pow() method

 // Java program to demonstrate working of java.lang.Math.pow() method  or how to implement power function in java
public class MathPower1 {
public static void main(String[] args) {
double nan = Double.NaN;
double result;
//2^NAN
result = Math.pow(2, nan);
System.out.println(result);
//1245^0
System.out.println(Math.pow(1245, 0));
//5^1
System.out.println(Math.pow(5, 1));
}

}


Java Math code

#Java_Program
#Java_Practice_Program

Saturday, September 28, 2019

thumbnail

Java Programming Basics - My First "Hello World !" code

Let's start, It is my first program in Java program Language.
The famous program in every language is "Hello World !"
Let's Start Java Programming Basics "Hello World !" code

Code




1) Write a program to display "Hello World!" in Java 

class HelloWorld 
{
public static void main(String[] args) 
{
System.out.println("Hello World!");
}
}

Output :

Hello World!



FullStackDeveloper. Powered by Blogger.