There is no difference between JSP and Servlet.
Server-Side Includes allows embedding servlets within HTML pages using a special servlet tag. In many servlets that support servlets, a page can be processed by the server to include output from servlets at certain points inside the HTML page. This is accomplished using a special internal SSINCLUDE, which processes the servlet tags. SSINCLUDE servlet will be invoked whenever a file with an. shtml extension is requested. So HTML files that include server-side includes must be stored with an . shtml extension.
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:
If no
JSP pages are focused around HTML (or XML) with Java codes and JSP tags inside them. When a web server that has JSP support is asked for a JSP page, it checks to see if it has already compiled the page into a servlet. Thus, JSP pages become servlets and are transformed into pure Java and then compiled, loaded into the server and executed.
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 .
Servlet chaining is a technique in which two or more servlets can cooperate in servicing a single request. In servlet chaining, one servlet?s output is piped to the next servlet?s input. This process continues until the last servlet is reached. Its output is then sent back to the client.
(1) Request Lifetime:
Using this technique to pass beans, a request dispatcher (using either "include" or "forward") can be called. This bean will disappear after processing this request has been completed.
Servlet:
request. setAttribute("theBean", myBean);
RequestDispatcher rd
= getServletContext(). getRequestDispatcher("thepage.jsp");
rd. forward(request, response);
JSP PAGE:
(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session (such as in individual user login) over a number of requests. This bean will
disappear when the session is invalidated or it times out, or when you remove it.
Servlet:
HttpSession session = request. getSession(true);
session. putValue("theBean", myBean); /* You can do a request dispatcher here, or just let the bean be visible on the next request */
JSP Page:
(3) Application Lifetime: Using this technique to pass beans that are relevant to all servlets and JSP pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet engine is shut down, or when you remove it.
Servlet:
GetServletContext(). setAttribute("theBean", myBean);
JSP PAGE:
Below are the different ways of communicating between
servlets :
Using Request
dispatcher Object.
Sharing resource
using ServletContext object.
Include response of
a resource in response of Servlet.
Calling public
method of the resource.
Servlet chaining.
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.
Just use the URL Pattern inside welcome file list with out begining slash.
Ads By Google
© 2018 - JavaSpartans.com • All Rights Reserved