Sep 13, 2012

Error: javax.servlet.jsp.JspException: Missing message for key "label.common.button.submit" in bundle "(default bundle)" for locale en_US

Description:

We get this error while using ApplicationResources.properties file and using the entry as below
<message-resources parameter="resources.ApplicationResources"/> (where the property file name is ApplicationResources.properties). The folder "resources" is in classpath, at the same level as the "src" folder in Eclipse IDE.

Solution:

The path mentioned in the struts-config file for the ResourceBundle should be in sync with where it is found within the /WEB-INF file in the classpath, in the ".war" file that was deployed (or) in the Eclipse IDE.

<message-resources parameter="ApplicationResources"/> 

Error: javax.servlet.jsp.JspException: Cannot find message resources under key org.apache.struts.action.MESSAGE

Description:

Struts is unable to find message resources. This issue occurs while using the Message Resources/Property files/Application Resources file

Solution:

Add the message-resources tag to the struts-config.xml file:
<message-resources parameter="resources.common.Common" />

Error: java.lang.IllegalArgumentException: The path of an ForwardConfig cannot be null

Description:

While using a Form with input fields, we get this error
<action path="/Login"
          name="userForm"
          type="com.dct.struts.learning.actions.UserAction">
          <forward name="success" path="/pages/login.jsp"></forward>
</action>

Solution:

This means after doing a validation, we need to specify where to be forwarded, incase of a failure. Hence the parameters "validate" and "input"(place from where it comes & to where it needs be forwarded) should be specified.
<action path="/Login"
           name="userForm"
           type="com.dct.struts.learning.actions.UserAction"
           validate="true"
           input="/login.jsp">
           <forward name="success" path="/pages/login.jsp"></forward>
</action>

Sep 11, 2012

Error : Struts1.x - Unable to add taglib tag in web.xml

Description:
When we add the <taglib> to the web.xml file, it keeps showing error.

<taglib>
       <taglib-uri>http://struts.apache.org/tags-bean</taglib-uri>
       <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
 </taglib>

Solution:
Enclose it within the <jsp-config> tag:

<isp-config>
       <taglib>
             <taglib-uri>http://struts.apache.org/tags-bean</taglib-uri>
             <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
       </taglib>
</jsp-config>

Jul 12, 2012

Object-oriented programming languages Vs. Object-based programming language

Object-oriented programming languages follow all the features of OOPS(Object-oriented programming system). Eg. Smalltalk, Simula-67, Java.
Object-based programming languages follow all the features of OOPS, except inheritence. Eg. JavaScript, VBScript.

Association, Aggregration, Composition, Generalization, Realization, Dependancy

Association:
Association is a relationship between 2 objects. (defines the relationship between objects like one-to-one, one-to-many, many-to-one, many-to-many)
eg. Student and Teacher, Student is related to the teacher
UML notation:


Aggregation:
Aggregation is a special type of association between 2 objects, where one object has a "has-a" relationship on another object. ie. one object contains another object. (A directional association between 2 objects)
eg. Class and Student, Class has Student.
UML notation:


Composition:
Composition is a special type of Aggregation, where one object contains another object and the contained object cannot exist with the container object.
eg. Wheel and Car, Wheel cannot exist without the car.
UML notation:



Generalization:
Generalization uses a "is-a" relationship from a Specialization to a Generalization class.
UML notation:


Realization:
Relation between a Class and its object. The object is said to realize the class.
UML notation:

Dependency:
If changes in the structure or behavior in one class affects another related class, then there is a dependancy between those 2 class. The vice-versa need not be true.
UML notation:

Jul 11, 2012

Abstraction, Encapsulation, Inheritence, Polymorphism

Abstraction:
Abstraction is the process of hiding the non-essential characteristics and showing only the essential characteristics to the user. [tbd: How is it achieved in Java]

Encapsulation:
Encapsulation is binding the data and the methods that act on it as a single unit. In Java, the data and the methods that act on the data are grouped as a single unit, the class.

Inheritance:
Inheritence is the process of creating new classes from existing classes. This enables the new classes to acquire all the inheritable features of the exisiting class. [tbd: How is it achieved in Java]

Polymorphism:
Polymorphism is the ability to assume different forms. In programming, the ability to use single variable to refer to objects of different types. In Java, Polymorphism is achieved thorough method over-riding.