Showing posts from April 7, 2012

Struts in Java

Suppose we create a application where we need to create a login page for user On passing correct credential user should be able to go at login success page while in case of errors user should go to login page again. A typical flow of struts application would be like below. 

First user will login from browser to open userLogin.jsp. This  HttpRequest will go to applications Web.xml File. with help of  request url, Web.xml file will find that its a struts request so it will reroute via ActionServlet. Action Servlet will get correct action mapping from Struts-config.xml. Request Processor will dispatch request with mapping & configuration information to get Action form. Action form validation will happen &  In case of any error response will go to browser. If there is no error Action classexecute method will be called. After performing action class logic action forward will be set as success or failure or anything. Based on result it will send HttpReponse to jsp which could be ei…

Jump on "Spring"......

How to initialize the Spring Application Context

Configuration in Web.xml

<context-param>   <param-name>contextConfigLocation</param-name>   <param-value>/WEB-INF/daoContext.xml  /WEB-INF/mainApp-context.xml  /WEB-INF/applicationContext.xml    </param-value> </context-param>
<listener>   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
multiple context file can be given separated by space or single context file which could import other context files in it.
One more option is there to load context with help of context loader servlet in-spite of listener as below.
<servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup></servlet>

The listener inspects the 'contextConfigLocation' parameter. If the parameter does not exist, the li…