Category: FromSitesTree.com

EJB 3: Stateless Bean #Java Short Notes

No need to maintain the state of a bean between calls. //CalculatorBean.java@Statelesspublic class CalculatorBean implements CalculatorRemote, CalculatorLocal{ public int add(int x, int y) { return x + y; } public int subtract(int x, int y) { return x – y; }}//CalculatorRemote.javaimport javax.ejb.Remote;@Remotepublic interface CalculatorRemote extends Calculator{}//CalculatorLocal.java import javax.ejb.Local;@Localpublic interface CalculatorLocal extends Calculator{}//Client.javaimport tutorial.stateless.bean.Calculator;import tutorial.stateless.bean.CalculatorRemote;import javax.naming.InitialContext;public …

Continue reading

EJB 2: How to build a stateless EJB #Java Short Notes

EJB 2: How to build a stateless EJB Install an EJB Server Specify the EJB Remote Interface Specify the Home Interface Write the EJB bean Class Create the ejb-jar File Deploy the EJB bean Write the EJB Client Run the Client From: http://sitestree.com/?p=4832 Categories:Java Short NotesTags: Post Data:2007-03-12 03:44:24 Shop Online: https://www.ShopForSoul.com/ (Big Data, Cloud, …

Continue reading

EJB 3: Statefull EJB #Java Short Notes

States need to be maintained between calls. In EJB3 all beans are homeless [no home interface]//ShoppingCartBean.javaimport java.io.Serializable;import java.util.HashMap;import javax.ejb.Remove;import javax.ejb.Stateful;import javax.ejb.Remote;@Stateful@Remote(ShoppingCart.class)public class ShoppingCartBean implements ShoppingCart, Serializable{ private HashMap cart = new HashMap(); public void buy(String product, int quantity) { if (cart.containsKey(product)) { int currq = cart.get(product); currq += quantity; cart.put(product, currq); } else { cart.put(product, …

Continue reading

Java XML Example – XML File Parse and Use Attributes #Java Short Notes

A good example: http://developerlife.com/tutorials/?p=25 Another very good example: http://www.developerfusion.co.uk/show/2064/: I followed this code to extract attribute values from an xml file. From: http://sitestree.com/?p=4776 Categories:Java Short NotesTags: Post Data:2009-07-22 04:37:22 Shop Online: https://www.ShopForSoul.com/ (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com In Bengali: http://Bangla.SaLearningSchool.com http://SitesTree.com 8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) Shop Online: https://www.ShopForSoul.com/ Medium: https://medium.com/@SayedAhmedCanada

MVC : Struts : Java : Industry Web Application #Java Short Notes

Industries use frameworks for application development quite often. For example: Java concepts like JSP, Servlet, Swing, Bean, JDBC can be used directly to create web-applications but when such applications become big, it becomes difficult to maintain and develop them further. Hence, frameworks like struts are used to develop large web-based Java applications. This makes maintenance …

Continue reading

Linked List and Iterator in Java #Java Short Notes

/* * LinkedList.java * * Created on January 10, 2008, 8:51 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package linkedlist;import java.util.List;import java.util.LinkedList;import java.util.Iterator;import java.util.ListIterator;import java.util.Collections;import java.util.Random;/** * * @author Sayed */public class LinkedListTest { /** Creates a new instance of LinkedList */ …

Continue reading

How to upload data from an excel file to database using servlets? #Java Short Notes

Use third party API bundles like jexcelApi. http://jexcelapi.sourceforge.net/. —create an XML file to define the structure of your excel file like how many columns, column names, corresponding database table/class column/variable name, Create a Java class that can retrieve information from that xml file. You can use XPATH and DOM for the purpose. check http://www.ibm.com/developerworks/library/x-javaxpathapi.html for …

Continue reading

Opening and reading files with Java JDK 1.0.x #Java Short Notes

1. Open the file with the File class; 2. Create a FileInputStream object using the File object; 3. Convert the FileInputStream to a BufferedInputStream to greatly increase file reading speed; 4. Convert the BufferedInputStream to a DataInputStream; the methods of DataInputStream give a fair amount of flexibility in reading the data. 5. Read the file …

Continue reading

Set, TreeSet, Iterator in Java #Java Short Notes #Blog

/* * TreeSetExample.java * *Illustrates mathematical set operations * * Created on January 10, 2008, 9:28 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package treesetexample;import java.util.Set;import java.util.TreeSet;import java.util.Iterator;/** * * @author Sayed */public class TreeSetExample { /** Creates a new instance of …

Continue reading

SCJP Training: Lesson 4: Concurrency #Java Short Notes #SCJP

Defining and Starting a Thread The SimpleThreads Example Thread Interference Memory Consistency Errors Synchronized Methods Intrinsic Locks and Synchronization Atomic Access Guarded Blocks From: http://sitestree.com/?p=5051 Categories:Java Short Notes, SCJPTags: Post Data:2006-11-03 06:59:23 Shop Online: https://www.ShopForSoul.com/ (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com In Bengali: http://Bangla.SaLearningSchool.com http://SitesTree.com 8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) Shop Online: …

Continue reading