Showing posts with label jsp. Show all posts
Showing posts with label jsp. Show all posts

April 14, 2017

J2EE Technologies Details explanation with examples


JDBC
Platform and vendor transparent access to SQL databases.
RMI-IIOP
J2SE RMI implementation over OMG's IIOP.
Java IDL
CORBA interoperability. Includes a lightweight ORB that supports IIOP.
Servlet
Server-side Web development. The "controller" layer. Middle tier flow-of-control logic.
JSP
Dynamic Web pages. The "view" layer. Middle tier presentation code.
JNDI
Unified enterprise naming API. A location-transparent repository for hierarchical data and relationships.
EJB
Component model for building "overhead free" business objects. The "model" layer. Middle tier business logic.
JMS
Asynchronous messaging that supports: queuing, publish-subscribe, and various aspects of push/pull technologies.
JTA
Distributed transaction demarcation API. Specifies a Java mapping to the X/Open XA transaction protocol.
JTS
Specifies the implementation of a Transaction Manager which supports the Java Transaction API (JTA) spec. Implements a Java mapping of the OMG Object Transaction Service (OTS).
Connector    
Legacy integration. The J2EE Connector architecture defines a standard architecture for connecting the J2EE platform to heterogeneous Enterprise Information Systems (e.g. mainframe transaction processing, database systems, ERP, and legacy applications not written in the Java programming language)
JavaMail
Platform and protocol-independent framework for building Java-based mail and messaging applications.


More Examples of J2EE Technologies
Read more ...

March 05, 2014

Latest Interview Questions on JAVA (Prepared by Sumitav Tripathy)

Wipro Interview Questions (Face to Face 1st March 2014)   For 4+ Experience.

·         Difference between Abstract Class & Interface?
·         Difference between Array List & Vector?
·         Difference between Array List & Linked List?
·         What is the script let in JSP can you write a script let for me.
·         For generating Excel from JSP what you do. I told Jasper Reports.
·         Explain the flow of Struts framework & how your project works on that.
·         What is MVC?
·          What is dependency injection?  How many types?
·         He asked about Spring AOP I told I do not know.
·         What is hibernate what are the advantages over JDBC?
·          How do you debug your Web Application?
·         What are the types of Loggers (specific to Log4J)
·         Which collection had you used in your project to access data from database I told HashMap
·         What is difference between HashMap & Hashtable?
·         Difference between Comparable & Comparator?
·         What is Marker Interface?
·         Difference between final, finally & finalize.
·         Difference between yield, join & sleep methods.
·         Why Strings are final. Why Strings are Immutable
·         What is difference between load & get java.
·         Difference between get & post.
·         What is difference between sendRedirect & forward?
·         JSP Lifecycle. Servlet life cycle. At which phase of JSP Lifecycle JSP converts to Servlet.
·         Do you know CSS & HTML.I told I know only basics?


IBS Interview Questions (Face to Face 27th Feb 2014):   For 4+ Experience
·         Difference between Array List & Vector.
·         Explain Spring Web MVC Flow
·         Difference between Abstract Class & Interface.
·         Difference between Array List & Linked List.
·         Write a program which will use all the same functions of ArrayList by using array like insertion, deletion without using any collection methods. Means create an ArrayList using array.
·         How many ways can you create Threads?
·         Tell me real time scenarios when to extend Thread class & when to implement runnable interface.
Which one is better?  In which scenario you will prefer extending Thread class to implement runnable interface.
 They asked about some exception in Multithreading which I had never heard.
·          There is a class which has 2 variables Employee name (String) & Employee Id(number ).
·         (a)Write a program (Here after read WAP as short form of  “Write a program”)  by using collection framework to sort according to the increasing order of employee Id. Which collection will you use  ?
·         (b) WAP by using collection framework to sort according to the alphabetical or
der of employee name. Which collection will you use?
·          How HashMap works?
·          Difference between yield, join & sleep methods.
·         What do you understand by immutability?
·         String  s=”Sumitav”; String  s1=new String (“Sumitav”);
·         s==s1    True/False ?   Also s.equals(s1);  what will be the output ?
·         Are only strings Immutable? I told no wrapper classes too.
I am writing a variable in an interface by default what will be its modifiers & access types I told “public static final” then they asked if one method is declared what will be the access specified. I told default write answer is public.
·         Can we write a constructor inside an Interface?  I told No
·         Then they asked can we write a constructor inside abstract class. I told yes then they asked what will be the purpose of this constructor if we cannot create object. I told for child class it will be used by super(); 
abstract class A {
     A(){ }
     abstract add();
}

Class B extends A {
A(){ }
add(){
sop("...");
}
}

·         Can you override the above constructor in child class? I was not sure.
·         Can an interface have a concrete method? I told no. Abstract class can have but not an interface.
·         What is second level cache in hibernate?
·         How you do Spring-Hibernate Integration.
·         Difference between default & private.


CapGemini Telephonic Interview Questions on 2nd March 2014:  For 4+ Experience.


·         What is Polymorphism what is the purpose.
·         What is Encapsulation? What is the purpose?
·         Flow of Struts according to your project.
·         Difference between Comparable & Comparator?
·          Difference between Hashtable & HashMap?
·         What is difference between sendRedirect & forward?
·         What is request Dispatcher?
·         Explain JSP Lifecycle.


Accenture Telephonic Interview  Questions on 10th March 2014:  For 4+ Experience

·         Can you tell me the life cycle of a servlet?
·         What is the difference between a servlet & JSP?
·         Can you tell me the difference between doGet & doPost. I told get passes data as query string so not safe.
·         Does get is faster than post?  I told I am not sure.
·         What is difference between JDK & JRE?
·         How you track a session & in how many ways can you track a session.  I answered cookies, URL rewriting & session.
·         You have a list you want to remove duplicates in the list. How will you do that ?  I told we have to use Set because set does not allow duplication. He told that’s what I was expecting.
·         How you compare a list of objects. I told comparable & comparator we have & the difference between them.
·         Have you worked on front end? I told yes then the interviewer asked how you do “pagination” in webpage. I asked pardon!!!! Question bounced J He asked do you understand what is pagination?  When you search in Google you search something at the bottom of the page you find 1, 2, 3…. That is called pagination. How will you do that? I told I think there may be some directives like JSP page directives. Just bluffed J I could not answer might be href of splitting table. How will you develop pagination in your application?
·         How will you debug a JavaScript .Suppose you have developed a Web application, you have used some JavaScript to validate your application right!!! Now you want to debug that web application, you have written one JavaScript function but in that JavaScript function something is going wrong. Now you have to identify the problem how will you identify?  I could not tell what I told was breakpoint, Starting server in debug mode then F5, F6, F7 etc. He told you are telling Java. I am asking how to debug JavaScript. You have written a function it should return either true/false how will you find out it is returning correctly true/false?
·         In JavaScript you have written an equation that equation is running but you don’t know that equation is returning correct value or not how will you identify that.
·         Have you worked on any JavaScript libraries? Like JQuery, DOJO? I told No.
·         Do you know what AJAX is? I told yes AJAX is advancement over JavaScript we use it for auto refreshing of web pages but I have not used.
·         How request processor is done in Struts.
·         How will it go to Action servlet?
·         In web.xml what will you define?
·         To deploy struts what will you write in web.xml?
·         Can you tell me which part of the Action class the business logic will be?
·         Can you tell me the definition of the execute ()? Syntax of execute () what are the signature, return type, input parameters, if it throws exception what exception type it throws?
·         Can you give the structure of Struts-config action tag? What will be inside? What is type generally?
·         How will you validate a form bean?
·         Have you worked in Tiles?
·         Can you describe validate & reset methods?
·         What will validate () returns?
·         Difference between Struts & Spring? What are the differences in the flow of both Struts & Spring?
·         Can you tell the difference get & load method in hibernate?
·         What is the difference between Sorted & ordered Collection in Hibernate?
·         What is lazy loading in hibernate? How it is achieved in Hibernate?
·         What is hibernate session & session factory?
·         Can we have multiple hbm files in Hibernate? How will you manage?
·         Difference between is session object & session lock?
·         Difference between ArrayList & Vector?
·         What is Serialization?
·         Why we need Serialization?
·         Why we use properties file?
·         Can we create objects without using new operator?
·         I have an object & I want to find out is it a String or Integer how can we find out?
String currentObject=12;
Object obj = (Object) currentObject;
If(obj instanceOf Integer){ String.out.println(“this Object is integer.”);
}else if(obj instanceOf String){ String.out.println(“this Object is String.”);
}
·         What are the types of polymorphism Java Supports?


These questions were faced by my friend Sumitav Tripathy (sumitav4job@gmail.com) & contributed to MYJAVACAFE after becoming successful.
Read more ...

October 11, 2012

Understanding JSP Life Cycle

JSP never outputs the content directly to the browser. Instead, JSP relies on initial server-side processing process which translates JSP page into the JSP Page class. The page class then will handle all the requests made of JSP. The JSP life cycle is described as the picture below:


JSP life cycle can be divided into four phases: Translation, Initialization, execution and finalization.

Translation

In the translation phase, JSP engine checks for the JSP syntax and translates JSP page into its page implementation class if the syntax is correct. This class is actually a standard Java servlet. After that, JSP engine compiles the source file into class file that is ready to use.
If the container receives the request, it checks for the changes of the JSP page since it was last translated. If no changes was made, It just loads the servlet otherwise the process of check, translate and compile takes place again. Because the compilation process takes time so JSP engine wants to minimize it to increase the performance of the page processing.

Initialization

After the translation phase, JSP engine loads the class file and create an instance of of the servlet to handle processing of the initial request. JSP engines will call a method jspInit() to initialize the a servlet. jspInit method is generated during the translation phase which is normally used for initializing application-level parameters and resources. You can also overide this method by using declaration.

<%!
   public void jspInit(){
      // put your custom code here  
   }
%>

Execution

After the initialization phase, the web container calls the method _jspService() to handle the request and returning a response to the client. Each request is handled is a separated thread. Be noted that all the scriptlets and expressions end up inside this method. The JSP directives and declaration are applied to the entire page so the are outside of this method.

Finalization

In the finalization phase, the web container calls the method jspDestroy(). This method is used to clean up memory and resources. Like jspInit() method, you can override thejspDestroy() method also to do your all clean up such as release the resources you loaded in the initialization phase....
<%!
   public void jspDestroy(){
      // put your custom code here 
      // to clean up resources
   }
%>
Read more ...

October 10, 2012

Responce once commited, any subsequent redirect operations will throw an IllegalStateException?

public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
PrintWriter out = response.getWriter();
String dbValue = getValueFromDB ();
if (dbValue == null) response.sendError (HttpServletResponse.SC_NOT_FOUND, "DB Lookup Failed");
response.sendRedirect ("Form.jsp");
}

Question:
Consider the following code snippet of above servlet code.
If the getValueFromDB () method returns null , which of the following statements are true?
(A) The code will work without any errors or exceptions
(B) An IllegalStateException will be thrown
(C) A NullPointerException will be thrown
(D) An IOException will be thrown

The correct answer(s):
(B) An IllegalStateException will be thrown
Explanation:
When the sendError() API is called, the response is considered committed and should not be written to
subsequently. Once the response is considered committed, any subsequent redirect operations will throw an
IllegalStateException.
In this above servlet code, the sendError() is invoked when the dbValue is null, which will cause the response to be
committed. Hence, the subsequent response.sendRedirect () method will then cause an IllegalStateException to
be thrown.
Reference: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html
Read more ...

My Favorite Site's List

#update below script more than 500 posts