Archive for the Programming Category

NonUniqueResultException in Hibernate

March 6, 2012
NonUniqueResultException in Hibernate

Sometimes we will get the NonUniqueResultException when we tried to get the result-set by executing query using Hibernate. The following is the stack trace of the exception: query did not return a unique result: 2 org.hibernate.NonUniqueResultException: query did not return a unique result: 2 at org.hibernate.internal.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:899) at org.hibernate.internal.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:890) at org.bss.dao.SampleDAO.main(SampleDAO.java:84) This happens because you’re expecting [...]

Parse the XML using DOM Parser in Java

December 8, 2011
Parse the XML using DOM Parser in Java

From Wikipedia http://en.wikipedia.org/wiki/Java_API_for_XML_Processing#DOM_interface, we can read like: The DOM interface is perhaps the easiest to understand. It parses an entire XML document and constructs a complete in-memory representation of the document using the classes modeling the concepts found in the Document Object Model(DOM) Level 2 Core Specification The following is the Java code to parse [...]

SCWCD / OCWCD Mock Exams

November 6, 2011
SCWCD / OCWCD Mock Exams

SCWCD / Oracle Certification Paths for JSP / Servlet Certification examination: Oracle Certified Professional, Java EE 5 Web Component Developer: Oracle J2EE 5 Exam Path Oracle Certified Expert, Java Platform, Enterprise Edition 6 JavaServer Pages and Servlet Developer: Oracle J2EE 6 Exam Path (Click on exam link of each page to find the syllabus of [...]

Difference between ServletRequest.getRequestDispatcher and ServletContext.getRequestDispatcher

October 26, 2011
Difference between ServletRequest.getRequestDispatcher and ServletContext.getRequestDispatcher

If you use ServletRequest.getRequestDispatcher: you can use absolute path like “/index.jsp“, which forwards request to “http://www.myapp.com/index.jsp” from the request received directory or you can use relative path like “index.jsp”, which forwards request to “index.jsp” which is relative to the request received servlet. For example, if you receive your request on “http://www.myapp.com/mymodule/”, RequestDispatcher requestDispatcher = request.getRequestDispatcher(“index.jsp”); [...]

 

If you have a Tip, Comment, Article or anything you want to share, please send it to: i@poisure.com