Sameer’s Blog

how ejb3 is differant from ejb2

Posted by: seesameer on: April 14, 2009

As java has progressed from 2003 to 2009. A lot of chnged in java and java ee… you can see so much of customizations from presentation layer to model layer and ofcourse controller part( with active support)…

EJB 3.0 is one of the major changes ( which makes easier to code if compared to its previous versions).

Major changes in ejb3.0 from ejb2.1

  • annotations ( not present in j2sdk1.4)
  • home interface removed, remote interface is very clear in ejb3.0( you don’t have to write “rmi” and related code..)
  • new persistence concept which removes some confusing concept in ejb2.0.
  • used as pojo removing vendor specific codes.. which is present in older versions of ejb.
  • the enterprise java beans runs on any server which support ejb3.0 specification.

Java Settings in linux…(Environment variables)

Posted by: seesameer on: August 22, 2008

Its very difficult for window user to work on Linux.

For developing any application we need to set so many
environment variables,classpath variables and path.
Its easy for window users as it gives so many options
for setting environment variables.
For Linux its tedious while setting any environment variable
(i tried 100 times..).
Here is a trick…
Please back up all files before u try something…(caution)
only superuser can change settings.
( Do It with some editor.. or open in terminal (vi editor))
go to root folder
/root
then edit bash_profile…( a hidden file)
(Linux versions differ in flavors..so be careful)
bash_profile which is hidden file and  superuser accessible.

this file contains (initially) path variable

something like path=/usr/…
after path variable press enter
and type whatever you want to set..
For ex:
CATALINA_HOME=/usr/local/tomcat
JAVA_HOME=/usr/local/jdk6
JBOSS_HOME=/usr/local/JBOSS4.2.2GA
JRE_HOME=/usr/local/JRE6

or if u want to set PATH variable.
after Path=/( some long list of path separated by : ) : /usr/local/jdk6/bin:/usr/local/JRE6/bin
by setting like this eclipse can search in path…
after saving bash profile…
type set in terminal and then check ( all environment variables will be there)
otherwise type in terminal (check the environment variable u wish to check..)

#echo $JAVA_HOME
/usr/local/jdk6
#_

Using Exadel to write Struts and JSF

Posted by: seesameer on: June 14, 2008

Exadel Studio provides an excellent ide support for
developing rich internet applications.Exadel Studio
can be used to write Struts and JSF applications.

Exadel Studio can be used with Eclipse 3.2 (But
it cannot be used on eclipse europa.. )

For More Details..

Go to.. www.exadel.com

A glimpse of Java Server Faces

Posted by: seesameer on: June 14, 2008

JavaServer Faces technology is a server-side user interface
component framework for Java technology-based web
applications. JavaServer(TM) Faces technology simplifies
building user interfaces for JavaServer applications.
JSF is an application framework for creating web based user
interfaces. JSF provides Web application lifecycle management
through a controller servlet.

JSF eases Web-based application development because it:

* Lets you create user interfaces from a set of standard,
reusable server-side components
* Provides a set of JSP tags to access those components
* Transparently saves state information and repopulates forms
when they redisplay
* Provides a framework for implementing custom components
* Encapsulates event handling and component rendering so you
can use standard

According to SUN:

JavaServer Faces technology is a server-side user interface
component framework for Java technology-based web
applications. A set of APIs for: representing UI components
and managing their state, handling events and input
validation,defining page navigation, and supporting
internationalization and accessibility.

A JavaServer Pages (JSP) custom tag library for expressing
a JavaServer Faces interface within a JSP page. JSF is built
on standard J2EE technologies,which include JSP tag
libraries,a controller servlet, and other Java classes that
make up its UI component library and event-processing model.

The Java Enterprise Edition 5 platform includes JavaServer
Faces (JSF) technology,which provides a mature and extensible
user interface component model.The design of this model makes
it easy for application developers to create custom components
by extending the standard components included with JSF and to
reuse these components across applications.

Tools supporting JSF-Java Server Faces:

* Borland JBuilder Enterprise Edition 2005
* Eclipse with Exadel Studio Pro IDE
* Eclipse with Nitrox JSF IDE
* IBM Rational with JSF Support
* Macromedia Dreamweaver with JSTL & JSF extensions
* MyEclipse with JSF Designer
* Oracle’s JDeveloper IDE
* Sun’s Java Studio Creator

Important Links For Developers

http://exadel.com/tutorial/jsf/jsftutorial-kickstart.html
http://resources.coreservlets.com/jsf.html
To Create Your Own Java Server Faces Components
http://www.jsftutorials.net/components/

How to write a simple struts application…

Posted by: seesameer on: April 5, 2008

The Struts project, an open−source project sponsored by the Apache
Software Foundation, is a server−side Java implementation of the
Model−View−Controller (MVC) design pattern.

The Struts projectwas originally created by Craig McClanahan in
May 2000.The Struts project was designed with the intention of
providing an open−source framework for creating Web applications
that easily separate the presentation layer and allow it to be
abstracted from the transaction/data layers. Since its inception,
Struts has received quite a bit of developer support, and is
quickly becoming a dominant factor in the open−source community.
All Struts applications are packaged using the Java Web
application format. Therefore,before we continue,let’s take a
brief look at Java Web applications.

Java Web applications are best described by the Java Servlet
Specification 2.4,which introduced the idea using the following
terms: “A Web Application is a collection of servlets, HTML pages,
classes, and other resources that can be bundled and run on
multiple containers from multiple vendors.”

In simpler terms, a Java Web application is a collection of one
or more Web components that have been packaged together for the
purpose of creating a complete application to be executed in the
Web layer of an enterprise application.Here is a list of the common
components that can be packaged in a Web application:Servlets,
Java Server Pages, custom tag libaries, java classes, configuration
files,static html files

Directory structure of web application ( Taking Tomcat as example…)

JSP pages are stroed in this directory
..<CATALINA_HOME>/webapps/APPLN_NAME/

classes are stored in <CATALINA_HOME>/webapps/APPLN_NAME/WEB-INF/classes/

configuration files tag libraries are stored in
<CATALINA_HOME>/webapps/APPLN_NAME/WEB-INF/

library files are stored in
<CATALINA_HOME>/webapps/APPLN_NAME/WEB-INF/lib/

The backbone of all Web applications is its deployment descriptor.
The Web application deployment descriptor is an XML file named
web.xml that is located in the
<CATALINA_HOME>/webapps/APPLN_NAME/WEB−INF/ directory.
The web.xml file describes all of the components in the Web
application.

Before starting development with struts we should get
struts-blank.zip from apache.Uncompress the Struts archive to your
local disk.Create a new Web application, using the directory structure
described above..

Struts is modeled after the MVC design pattern, you can follow a
standard development process for all of your Struts Web applications.
This process begins with the identification of the application Views,
the Controller objects that will service those Views, and the Model
components being operated on. This process can be described using
the following steps:

Define and create all of the Views, in relation to their purpose,
that will represent the user interface of our application.

Add all ActionForms used by the created Views to the struts−config.xml
file.

Create the components of the application’s Controller.

Define the relationships that exist between the Views and the
Controllers (struts−config.xml).

Make the appropriate modifications to the web.xml file; describe the
Struts components to the Web application.

Run the application.

Views… inpuname.jsp and greeting.jsp

inputname.jsp

<%@ taglib uri=”/WEB-INF/struts-html” prefix=”html” %>

<html:html>
<head>
<title>Struts Hello World</title>
</head>
<body>
<html:form action=”/greeting.do”>
<table border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td><b>Input name:</b></td>
</tr>
<tr>
<td>
<html:text property=”name” />
<html:submit value=” Say Hello! ” />
</td>
</tr>
</table>
</html:form>
</body>
</html:html>

greeting.jsp

<html>
<head>
<title>Greeting Struts Application</title>
</head>
<body>
<table border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td>
<h1><%=request.getAttribute(”greeting”)%></h1>
</td>
</tr>
</table>
</body>
</html>

struts-config.xml file

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE struts-config PUBLIC “-//Apache Software Foundation//DTD Struts Configuration 1.2//EN”
“http://struts.apache.org/dtds/struts-config_1_2.dtd”>
<struts-config>
<data-sources/>
<form-beans>
<form-bean name=”Form” type=”sameer.Form”/>
</form-beans>
<global-exceptions/>
<global-forwards>
<forward name=”name” path=”/pages/inputname.jsp”/>
</global-forwards>
<action-mappings>
<action name=”Form” path=”/greeting” scope=”request” type=”sameer.GreetingAction”>
<forward name=”sayhello” path=”/pages/greeting.jsp”/>
</action>
</action-mappings>
<controller/>
</struts-config>

java classes..

package sameer
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

public class Form extends ActionForm {
private String name=”";

public Form() {
}

public void reset(ActionMapping actionMapping, HttpServletRequest request) {
this.name=”";
}

public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
ActionErrors errs = new ActionErrors();
return errs;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = (name==null?”":name);
}
}

Action class

package sameer

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class GreetingAction extends org.apache.struts.action.Action {

// Global Forwards
public static final String GLOBAL_FORWARD_getName = “name”;

// Local Forwards
private static final String FORWARD_sayhello = “sayhello”;

public GreetingAction() {
}

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String name = ((sameer.Form)form).getName();
String greeting = “Hello, “+name+”!”;
request.setAttribute(”greeting”, greeting);
return mapping.findForward(FORWARD_sayhello);
}
}

using ant to build application…..

Posted by: seesameer on: March 29, 2008

We need a tool which will help in making application simpler and faster. The answer is ant…

To use ant you should have eclipse or you should get ant

Before installing ant you should have JDK installed. JAVA_HOME should point to appropriate JDK.

Set ANT_HOME to binary distribution of ant.. depending upon your system(Windows,Unix)…

Example : ANT_HOME = D:\sameer\apps\ant

after setting… check in command prompt

ant -version press enter..

You will get this…

 

Sample build file for web application.. which can be used in eclipse…

<?xml version=”1.0″ encoding=”UTF-8″?>
<!– ======================================================================
Date: 29 MAR 2008
project: APPL NAME

Author:Sameer
======================================================================= –>
<project name=”APPL NAME” default=”delete”>
<description>
<!– Description About Project –>
</description>

<target name=”delete” description=”Delete bin,build and deploy directories”>
<delete dir=”bin”/>
<delete dir=”build”/>
<delete dir=”deploy”/>
<echo>Delete was successfull</echo>
</target>

<target name=”init”>
<tstamp />
</target>

<!–Create a build directories–>
<target name=”prepare” description=”Create build directories”>
<mkdir dir=”build” />
<mkdir dir=”build/APPL NAME/WEB-INF/classes” />
<mkdir dir=”build/APPL NAME/WEB-INF/lib” />
<mkdir dir=”build/APPL NAME/gui/jsp”/>
</target>
<!– create bin directories–>
<target name=”bin” description=”Create bin directory” >
<mkdir dir=”bin”/>

</target>

<!–Create Deploy Directories–>
<target name=”deploy” description=”Create deploy directory”>
<mkdir dir=”deploy”/>
</target>

<!–Create Documentaion Directory–>
<target name=”doc” description=”Create Document Directory”>
<mkdir dir=”docs”/>
<mkdir dir=”docs/Architecture”/>
</target>

<!–Create GUI directory–>
<target name=”gui” description=”Create GUI Directory”>
<mkdir dir=”gui”/>
<mkdir dir=”gui/config”/>
<mkdir dir=”gui/jsp”/>
</target>

<!–Create Lib Directory–>
<target name=”lib” description=”Create Lib Directory”>
<mkdir dir=”lib”/>
</target>
<!–Create tld files Directory–>
<target name=”tags” description=”Create tags files Directory”>
<mkdir dir=”tags”/>
</target>
<!–Create Properties–>
<target name=”property” description=”Create Property Directory”>
<mkdir dir=”properties”/>
</target>

<!–Create Source folder Structure–>
<target name=”src” description=”Create Source Directory”>
<mkdir dir=”src”/>
<mkdir dir=”src/org/apps”/>
</target>

<!– Compile all SRC java files –>
<target name=”compile” description=”Compile all java files from src directory and copy class files into bin directory”>
<javac srcdir=”src” destdir=”bin”
debug=”on” deprecation=”off”>
</javac>
</target>

<!–Generate a build path–>
<target name=”copy” description=”Copy all source class files to form a build path”>
<!–copy all gui folder to build structure–>
<copy todir=”build/APPL NAME/gui”>
<fileset dir=”gui/jsp”></fileset>
</copy>

<!–copy all bin class files to build structure–>
<copy todir=”build/APPL NAME/WEB-INF/classes”>
<fileset dir=”bin” excludes=”**/*.java”></fileset>
<fileset dir=”properties”></fileset>
</copy>

<!–copy all liberary files to build structure–>
<copy todir=”build/APPL NAME/WEB-INF/lib”>
<fileset dir=”lib”></fileset>
</copy>

<!–copy all tags files and xml files to build structure–>
<copy todir=”build/APPL NAME/WEB-INF/tags”>
<fileset dir=”tags”></fileset>
<fileset dir=”gui/config”></fileset>
</copy>
</target>

</project>
<!–End of APPL NAME Project–>

Sheela’s Marriage… and Talkadu Trip..

Posted by: seesameer on: March 23, 2008

It started with Saturday morning and it was last day for our team lead…:(as he was leaving our company.. But good news is that he was coming with us for marriage…we already booked Toyata Qualis. We were already late because of party.. so we left at 5 pm.We were totally 9 members including a alval(always talkative) driver.

It took 3 hours to reach kodegal. The road was so good that we danced in qualis haphazardly. After reaching kodegal sheela’s brother came as we didn’t know exact address. He took us to the lodge and then to the kalyan mantap.

In kalyan mantap only cameras are moving and humans were still to get best shot. After photo session we had dinner.. Next morning we attended the rituals of marriage…

In Afternoon we went to talkadu…(amazing place). the city was so clean.. the river side was amazing…tall trees blue sky.. wonderful place….

The beach was occupied by so many people.. we really enjoyed it..

Blog Stats

  • 532 hits

 

July 2009
M T W T F S S
« Apr    
 12345
6789101112
13141516171819
20212223242526
2728293031