Email Subscriptions

Enter your email address:

Delivered by FeedBurner

Thursday, March 18, 2010

Applet Servlet Communication

following code can be used at applet side :

/*
*URL to servlet
*/

URL serverURL = new URL(servletPath);

URLConnection connection = serverURL.openConnection();
/*
* Connection will be used for both input and output
*/
connection.setDoInput(true);
connection.setDoOutput(true);

/*
* Disable caching
*/
connection.setUseCaches(false);

/*
*connection will be used for transfaring serialized java objects.
*/
connection.setRequestProperty("Content-Type", "application/octet-stream");

ObjectOutputStream outputStream = new ObjectOutputStream(connection.getOutputStream());

outputStream.writeObject(request);
outputStream.flush();
outputStream.close();

ObjectInputStream inputStream = new ObjectInputStream(connection.getInputStream());

response = (Map)inputStream.readObject();
inputStream.close();


Here response is the response Map returned from servlet.

following code can be used in your servlet to send serializable objects to applet.

write this code in doXXX method of servlet.

ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
Map responseMap = new HashMap();
/*
put watever objects you wants to return to applet.
This objects must be serializable.

responseMap.put("a", "a");

*/
out.writeObject(responseMap);
out.flush();
out.close();
response.setStatus(HttpServletResponse.SC_NO_CONTENT);

Sunday, February 7, 2010

Preparing for Interview On Java?..Core

1. objects
a. polymorphism
b. inheritance
c. encapsulation
d. abstraction

2. strings
a. string equality
b. immutable

3. exception handling.
a. throwable
b. exceptions and errors
c. checked exceptions
d. overriding exceptions

4. threads
a. wait,notify,notifyall
b. Ready state
c. synchronization
d. sleep
e. interrupt exception

Collections

Things need to work on...

JAMES: MAIL SERVER

http://james.apache.org/server/head/index.html

Wednesday, January 27, 2010

DB questions thread

META DATA TABLE SUMMARY

-------------------------------------------


syscat.tabconst -- to find out all FOREIGN KEY & PRIMARY KEY constraints
of a schema
syscat.references -- TO SEE fk - pk relations
syscat.keyclouse -- to see columns of a constraint
syscat.checks -- for all check constraints of a schema
syscat.indexes -- for unique / non unique indexes.






oRACLE FOREIGN KEY FINDING:

In Oracle 9i, you can find out references table and constraints.

select owner,constraint_name,constraint_type,table_name,r_owner,
r_constraint_name
from all_constraints
where constraint_type='R'
and r_constraint_name
in (select constraint_name
from all_constraints
where constraint_type in ('P','U')
and table_name='APC_WORKSPACES');


iN db2 FORIEGN KEY FINDING:


select reftabname from syscat.references where tabname = 'table1'



Different ways you can do this :
1)
select substr(tabname,1,20) table_name,substr(constname,1,20) fk_name,substr(REFTABNAME,1,12) parent_table,substr(refkeyname,1,20) pk_orig_table,fk_colnames from syscat.references where tabname = 'TABLE_NAME'
2)
Use the command :
db2look -d -t -a -e -c
Look for 'DDL Statements for foreign keys on Table table_name in the output.
3)
Alternatively, If you have access to control center, right click on the table and select 'generate ddl'.

Sunday, January 24, 2010

Tips...

when d u want to use and interface and when u want to use an abstract class while designing classes?

Abstract classes: When you want to model the homogeneous objects use an abstract class to phase out in abstract class common data constants or variables and behavior.
Restrictions can be placed via abstract class on inheriting classes.

Interface: When you got to model heterogeneous objects then common constants you might want to phase out, or providing .

to be edited.....


-------------------------------------------------

pie

polymorphism, inheritance and encapsulation.


The ‘is a’ relationship is expressed with inheritance and ‘has a’ relationship is expressed with composition.

Which one to use? The guide is that inheritance should be only used when subclass ‘is a’ superclass.

�� Don’t use inheritance just to get code reuse. If there is no ‘is a’ relationship then use composition for code reuse. Overuse of implementation inheritance (uses the “extends” key word) can break all the subclasses, if the superclass is modified.
�� Do not use inheritance just to get polymorphism. If there is no ‘is a’ relationship and all you want is polymorphism then use interface inheritance with composition, which gives you code reuse (Refer Q8 in Java section for interface inheritance).


What is the difference between aggregation and composition?
Aggregation Composition: Aggregation is an association in which one class
belongs to a collection. This is a part of a whole relationship where a part can exist without a whole.For example a line item is a whole and product is a
part. If a line item is deleted then corresponding product need not be deleted. So aggregation has a weaker relationship.

Composition is an association in which one class belongs to a
collection. This is a part of a whole relationship where a part
cannot exist without a whole. If a whole is deleted then all parts are
deleted. For example An order is a whole and line items are parts.
If an order deleted then all corresponding line items for that order
should be deleted. So composition has a stronger relationship.