HI,
i am new to Spring framework.right now in our project we are working in spring framewok(Mvc Architecture layer).
The issues which i am facing here is i don't know how to call the "EJB CONTROLLER"(which is another layer) from the controller (which is nothing but the
servlet) using the "Spring Framwork"
can anybody guide me to foundout the solution for this issue.So that i can proceed further.....Below are the details of my codings
Controller(servlet)
package com.trctc.login.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.validation.*;
import com.trctc.login.bd.LoginBD;
import com.trctc.login.bd.Logindelegate;
import com.trctc.login.dto.LoginDTO;
import com.trctc.login.ejbctrl.LoginEJBCtrl;
import com.trctc.login.form.LoginForm;
import com.trctc.login.bd.LoginBD;
import org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean;
//import com.trctc.login.form.LoginForm;
/**
* Servlet implementation class for Servlet: LoginController
*
*/
public class LoginController extends AbstractCommandController{
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
private LoginBD loginBD;
public LoginController() {
setCommandClass(com.trctc.login.form.LoginForm.class);
}
@Override
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, BindException error) throws Exception {
try {
System.out.println("Control in Controller");
LoginDTO loginDTO = new LoginDTO();
LoginForm loginForm=(LoginForm)command;
System.out.println("Value of User name : " + loginForm.getUsername());
System.out.println("Value of Password : " + loginForm.getPassword());
loginDTO.setUserName(loginForm.getUsername());
loginDTO.setPassword(loginForm.getPassword());
System.out.println("Value of User name : " + loginDTO.getUserName());
System.out.println("Value of Password : " + loginDTO.getPassword());
//Variable userFlag holds the status of the user.
String userFlag = "Fail";
userFlag = loginBD.verifyLogin(loginDTO);
//LoginBD loginBD = null;
/*Logindelegate logindelegate=new Logindelegate();
userFlag=logindelegate.verifyLogin(loginDTO);*/
System.out.println("user Status.."+userFlag);
} catch (Exception e) {
System.out.println("Exception in Controller");
e.printStackTrace();
}
return new ModelAndView("welcome.jsp");
}
public void setLoginBD(LoginBD loginBDImpl){
this.loginBD=loginBDImpl;
}
}
=======================================================================
TRCTC_Servlet.xml
Dispatcher File for the Springs)
------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <!-- the application context definition for the springapp DispatcherServlet -->
<!-- <bean name="/hello.htm" class="springapp.web.HelloController" /> -->
<bean name="/login.trs"
class="com.trctc.login.controller.LoginController">
<property name="loginBD" ref="loginBDImpl" />
</bean>
<bean id="loginBDImpl" class="com.trctc.login.bd.LoginBDImpl" />
<!--<bean id="loginEJBCtrl" class="com.trctc.login.bd.LoginBDImpl">
<property name="loginEJBCtrl" ref="LoginEJBref" />
</bean>
<bean id="LoginEJBref" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean">
<property name="jndiName" value="ejb.LoginSLEJBRemoteHome"/>
<property name="businessInterface" value="com.trctc.login.ejbctrl.LoginEJBCtrl"/>
</bean>
-->
</beans>
===========================================================================