JavaSpartans
Java J2ee Struts Hibernate Spring Interview Questions Java J2ee Struts Hibernate Spring Interview Questions
106 Results; Time:0.06 Sec; Page : 1 ; Results From 1 to 10. Results Per Page
1 2 3 4 5 6 7 8 9 10 11   Next >>

1. What is the capacity of the session object ? What is the maximum amount of data that you could store inside a session ?

There is no limit on the session memory or capacity.
It totally depends on the JVM Heap Memory.
It depends on the RAM of your server infrastructure.
Even if the RAM is not enough, the Virtual memory concept is there...

So you can put any amount of data inside a session, but burdening session will significantly cause performance issues.

2. How do you implement logging in Servlets ?

Just implement log4j as it is the good one. Download the jar or add its details in maven. in log4j.xml or .properties file add configuration .

3. What is the default session timeout for web applications ?

The default session timeout for J2EE web applications is 30 minutes. This value is specified in the web.xml file of your web application. 
<!-- ==================== Default Session Configuration ================= -->
  <!-- You can set the default session timeout (in minutes) for all newly   -->
  <!-- created sessions by modifying the value below.                       -->

    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

We can also set the session timeout values programmatically. In that case we will override the default value which is specified in web.xml file.
You can provide a negative value here to indicate that the session never expires like this session.setMaxInactiveInterval(-1);
or
session.setMaxInactiveInterval(36000); which is equals to 10*60*60
getMaxInactiveInterval(), getLastAccessedTime() can be used as per your requirement.

We have to observe that the tagged one is in minutes and this one which we are explicitly setting is in Seconds.

4. What is a persistent cookie ?

A persistent cookie is a data file (a small text file) capable of providing websites with user preferences, settings and information for future visits. Persistent cookies provide convenient and rapid access to familiar objects, which enhances the user experience (UX).
A persistent cookie is also known as a stored or permanent cookie.

Non-Persistent cookies are otherwise called as temporary cookies. They are active as long as the browser remains active or user session is active. They are also called as session based cookies. While Persistent cookies are permanent cookies. They are stored as a text file in the hard disk of the computer.

5. What is the purpose of <load-on-startup> tag in web.xml ?

This tag specifies that the servlet should be loaded automatically when the web application is started.

The value is a single positive integer, which specifies the loading order. Servlets with lower values are loaded before servlets with higher values (ie: a servlet with a load-on-startup value of 1 or 5 is loaded before a servlet with a value of 10 or 20).

When loaded, the init() method of the servlet is called. Therefore this tag provides a good way to do the following:

  • start any daemon threads, such as a server listening on a TCP/IP port, or a background maintenance thread
  • perform initialisation of the application, such as parsing a settings file which provides data to other servlets/JSPs

If no value is specified, the servlet will be loaded when the container decides it needs to be loaded - typically on it's first access. This is suitable for servlets that don't need to perform special initialisation.

6. How to use a servlet as your main web page, instead of redirecting to a servlet from your index.jsp page

Just use the URL Pattern inside welcome file list with out begining slash.

7. How do you handle the session time-outs ? How will you inform to the user that a session has expired assume that you have set the time out to 2 mins in web.xml ?

Please Answer

8. What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher() ?

9. What is the difference between ServletContext and PageContext ?

10. What is the difference between JspWriter & PrintWriter ?


Java J2ee Struts Hibernate Spring Interview Questions
106 Results; Time:0.06 Sec; Page : 1 ; Results From 1 to 10. Results Per Page
1 2 3 4 5 6 7 8 9 10 11   Next >>
Menu - javaspartans.com - Java J2ee Struts Spring Hibernate Interview Questions
Hostens.com - A home for your website
Ads By Google