Posts

Showing posts from November, 2010

Apache load balancing for Tomcat Example (with Wamp server apache module (Apache2.2.xx))

This is continued from the previous post in here . Scenario: You have application running on two tomcat servers. Example is for localhost. Replcae it with relevant IP addresses which the tomcat servers are runing. 1. http://localhost:8080/app/ 2. http://localhost:8090/app/ You need to load balance between two tomcat servers through apache server as well as to hide the actualURLs from outside. Here is the Step by Step instructions. 1. First follow the previous post and configure apache proxy. 2. Let's write a balancer configuration named "mybalancer" with two members who are two tomcat servers. The load should be balanced between those two members (1:1). Add the following segment to httpd.conf file. < PROXY balancer://mybalancer > BalancerMember http://localhost:8080 BalancerMember http://localhost:8090 </ PROXY > 3. Now change the ProxyPass statement to refer the balancing cluster. For that replace line ProxyPass /proxydemo/ http://localhost

Apache proxy configuration for Tomcat Example (with Wamp server apache module (Apache2.2.xx))

Apache Proxy Configuration - To place Tomcat server behind apache server Scenario: You have tomcat server applications ( http://localhost:8080/app/ , etc)which need to be placed behind a apache server. In this example apache port is 9090. You can have your own ports. First download WampServer2.0i file and install in your machine. Start Wamp and start apache service (Click on wamp icon in toolbar and go to apache-Service-Start/Resume Service ) In you wamp installation directory go to it's apache module and open httpd.conf file. (WAMP_HOME\bin\apache\Apache2.2.11\conf\httpd.conf) 1. Here you have to enable following modules.                                   LoadModule proxy_module modules/mod_proxy.so                                   LoadModule proxy_http_module modules/mod_proxy_http.so                                    LoadModule rewrite_module modules/mod_rewrite.so Search them in httpd.conf file and uncomment them. (Remove # mark infront of each module entry) Now r

Java-Simple way to check command line input to enter a number-Give error message if not a number and ask again to input

If you want to take a commandline input through BufferedReader or Scanner and you want user to enter a number. So in this solution user is asked to enter a number and if it is not a number (throws NumberFormatException) error message is displayed and again asks for user to enter. Until user enters a number this continues. This is simple. Here is the code with comments explaining the code. import java.io.*; class InputNumber{ public static void main(String args[]){ boolean success=false; String value=null; int number_value=0;//number value is stored System.out.print("Enter Number:"); //loop continues until user entered a number,success //will assigned true when user entered a number and while //loop will terminate while (!success){ try{ BufferedReader bf=new BufferedReader (new InputStreamReader(System.in)); value=bf.readLine(); number_value=Integer.parseInt(value