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, …
Category: FromSitesTree.com
Jul 17
Unit Testing in Eclipse for Java #Java Short Notes
Unit Testing in Eclipse for Java: just an overview Why Unit Test? Say, you have written some Java classes, before making use of them in real application functionalities, it’s always better to check whether the classes (their functions/methods) are working properly. Unit tests simply test a single unit like a single class, or a single …
Jul 17
What is Spring Framework? What does it mean to J2EE developers #Java Short Notes
What is Spring Framework? What does it mean to J2EE developers? Spring is a light-weight framework, very often referred as an alternative/competitor to EJB, for the development of enterprise-type applications. Spring provides many features such as declarative transaction management, access to remote logic using RMI or web services, mailing facilities and database abstraction. Features of …
Jul 17
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
Jul 17
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 …
Jul 17
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 */ …
Jul 17
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 …
Jul 17
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 …
Jul 16
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 …
Jul 16
SCJP Training: Lesson 3: API Contents #Java Short Notes #SCJP
The Number Classes Characters Strings The StringBuilder Class Character Streams (FileReader, FileWriter) Buffered Streams (BufferedReader, BufferedWriter) Formatting (PrintWriter) File Objects (File) Data Streams Object Streams Manipulating Characters in a String (String split method) Methods of the Pattern Class Methods of the Matcher Class Scanning Formatting Formatting (PrintWriter, formatting parameters) Formatting Numeric Print Output (formatting parameters) …
