Search This Blog

Tuesday, September 18, 2012

How to run the Shell script file in Linux


In Linux Environment i am having the following shell script file.

Ex: setEnvironmentVariables.sh which contains the following

#!/bin/sh
DYNAMO_HOME=/ATG/ATG9.4/home
JAVA_HOME=/Weblogic/utils/bea1035/jdk1.6.0_29
WL=/Weblogic/utils/bea1035/user_projects/domains/ mydomain
WL_HOME=/Weblogic/utils/bea1035/wlserver_10.3
PATH=$JAVA_HOME/bin:$WL_HOME/server/bin:$PATH
export PATH

1.Syntax
               . setEnvironmentVariables.sh

This dot operator is very important.

2.While Running the shell scripts ,we dont need to mention the .sh because each shell script file should contain #!/bin/sh.This will be used  to  acknowledge that it was a shell script file.we can also run as follow.

           . setEnvironmentVariables


How to increase the FONT size in Eclipse IDE

Step1: open the eclipse IDE.

Step2: Goto the following

Windows
            > Preferences
                       > General
                                > Appearance
                                         > Colors and Fonts
                                                      >Basic
                                                            > Text Font

Step3: Double click the Text Font option.

Step4: Set Eclipse Font Size,Apply,OK                               

Step5: We can also set it in Java Editor instead of BAsic

Java > Java Editor Text Font > EDIT.

Thursday, December 22, 2011

passing javascript value to scriplet tag

<html>
<script>
function selectValue()
{
var myChoice = document.form.bikeBrand.options[document.form.bikeBrand.selectedIndex].text;
window.location.replace("passValue.jsp?value="+myChoice);
}
</script>
<form name="form" >
<select name="brand" id="bikeBrand" onchange="selectValue();">             
<option value="<-Select->"><- Select- ></option>             
<option value="Honda">Honda</option>             
<option value="TVS">TVS</option>             
<option value="Bajaj">Bajaj</option>             
</select>           
</form> 
         
<% String str=request.getParameter("value");           
if(str!=null)          
out.println("Selected value is="+str);            
%>
</html>

Friday, December 16, 2011

Java Naming Conventions

1.What Is a Naming Convention?
A naming convention is a rule to follow, as you decide what to name your identifiers (e.g. class, package, variable, method, etc..).


2.Why Use Naming Conventions?
By using standard Java naming conventions they make their code easier to read for themselves and for other programmers. Readability of Java code is important because it means less time is spent trying to figure out what the code does, leaving more time to fix or modify it.

To illustrate the point it's worth mentioning that most software companies will have a document that outlines the naming conventions they want their programmers to follow. A new programmer who becomes familiar with those rules will be able to understand code written by a programmer who might have left the company many years before hand.


3.Picking a Name for Your Identifier
When choosing a name for an identifier make sure it's meaningful. For instance, if your program deals with customer accounts then choose names that make sense to dealing with customers and their accounts (e.g., customerName, accountDetails). Don't worry about the length of the name. A longer name that sums up the identifier perfectly is preferable to a shorter name that might be quick to type but ambiguous.


4.Cases

Using the right letter case is the key to following a naming convention:

Lowercase is where all the letters in a word are written without any capitalization
(e.g. mypackage).

Uppercase is where all the letters in a word are written in capitals. When there are more than two words in the name use underscores to separate them
(e.g., MAX_HOURS, FIRST_DAY_OF_WEEK).

CamelCase (also known as Upper CamelCase) is where each new word begins with a capital letter
(e.g., CustomerAccount, PlayingCard).

Mixed case (also known as Lower CamelCase) is the same as CamelCase except the first letter of the name is in lowercase
(e.g., customerFirstName, customerLastName).
Standard Java Naming Conventions:

The below list outlines the standard Java naming conventions for each identifier type:

Packages:
Names should be in lowercase. In software companies and large projects where the packages might be imported into other classes, the names will normally be subdivided. Typically this will start with the company domain before being split into layers or features:
e.g., package com.vam.utilities
package org.bobscompany.application.userinterface

Classes:
Names should be in CamelCase. Try to use nouns because a class is normally representing something in the real world:
e.g., class Customer
class Account

Interfaces:
Names should be in CamelCase. They tend to have a name that describes an operation that a class can do:
e.g., interface Comparable
interface Enumerable

Note: some programmers like to distinguish interfaces by beginning the name
with an "I":
e.g., interface IComparable
interface IEnumerable

Methods:
Names should be in mixed case. Use verbs to describe what the method does:
e.g., void calculateTax()
string getSurname()

Variables:
Names should be in mixed case. The names should represent what the value of the variable represents:
e.g., string firstName;
int orderNumber ;
Only use very short names when the variables are short lived, such as in

for loops:
e.g., for (int i=0; i<20;i++)
{
//i only lives in here
}

Constants:
Names should be in uppercase.
e.g., static final int DEFAULT_WIDTH;
static final int MAX_HEIGHT ;

Passing value from javascript to jsp page

write the javascript function to pass javascript value as a queryString

For Ex sample.jsp :
-------------------

step1:

function passValue(){
var jsValue="India";
window.location.replace("sample.jsp?message="+jsValue);
}

step2:

Add the html button to call the passValue() method during onclick

input type="button" onclick="passValue();" value="click"

<%String message=request.getParameter("message");
out.println(message);
%>