Servelt - web.xml
---------------------
<servlet>
<display-name > InitParamTest </display-name >
<servlet-name > InitParamTest </servlet-name >
<servlet-class >
test.InitParamTest </servlet-class >
<init-param >
<description > test parameter </description >
<param-name > myname </param-name >
<param-value > DummyValue </param-value >
</init-param >
</servlet >
load-on-startup - servlet startup order while loading the web.xml
Filter - servlet
A filter is an object that can transform a request or modify a response.
Filters are not servlets; they don't actually create a response.
They are preprocessors of the request before it reaches a servlet,
and/or postprocessors of the response leaving a servlet.
* void init(FilterConfig config) throws ServletException: Called before the filter goes into service, and sets the filter's configuration object
* void destroy(): Called after the filter has been taken out of service
* void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException: Performs the actual filtering wor
filter-mapping - It is used to map with the particular Filter for particular url pattern
ServletConfig vs ServletContext
---------------------------------
ServletConfig has servlet wide scope. It is defined inside
---------------------
test.InitParamTest
load-on-startup - servlet startup order while loading the web.xml
Filter - servlet
A filter is an object that can transform a request or modify a response.
Filters are not servlets; they don't actually create a response.
They are preprocessors of the request before it reaches a servlet,
and/or postprocessors of the response leaving a servlet.
* void init(FilterConfig config) throws ServletException: Called before the filter goes into service, and sets the filter's configuration object
* void destroy(): Called after the filter has been taken out of service
* void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException: Performs the actual filtering wor
filter-mapping - It is used to map with the particular Filter for particular url pattern
ServletConfig vs ServletContext
---------------------------------
ServletConfig has servlet wide scope. It is defined inside
in web.xml
ServletContext has application wide scope . It is defined outside the tag in web.xml
context parameters – available to the entire scope of the web application
- init parameters – available in the context of a servlet or filter in the web application
--------------------------------------------------------------------------------------------------------------
context parameters – available to the entire scope of the web application
- init parameters – available in the context of a servlet or filter in the web application
--------------------------------------------------------------------------------------------------------------
Struts Action Class
-------------------
1.ForwardAction class
2.DispatchAction class
An abstract Action that dispatches to a public method that is
named by the request parameter whose name is specified by the
parameter property of the corresponding ActionMapping.
This Action is useful for developers who prefer to combine
many similar actions into a single Action class, in order to simplify their application design.
<action path="/saveSubscription" type="org.apache.struts.actions.DispatchAction"
name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="method"/
3.IncludeAction class
4.LookUpDispatchAction class
It will dispatch to the particular public method based on a method getKeyMethodMap.
This is useful in cases where an HTML form has multiple submit buttons.
getKeyMethodMap - button key value is mapped to a function (hasmap button key value, function name)
5.MappingDispatchAction class
6.SwitchAction class
7.LocaleDispatchAction class
8.DownloadAction class
Multiple Reource files in struts
--------------------------------
<message-resources
parameter="resources.DefaultResource"/ >
<message-resources
parameter="resources.Registration"
key="registrationBundle"/>
if both resources have same property
(label.common.message), then can able to print
<bean:message
key="label.common.message" bundle="registrationBundle"/>