[jboss-user] [Installation, Configuration & Deployment] - Re: Jboss install

jgayathri do-not-reply at jboss.com
Sun Apr 15 23:58:15 EDT 2007


/*

 * SessionTestServlet.java

 *

 */



package test.session;



import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import javax.naming.*;

import javax.rmi.PortableRemoteObject;





/**

 * @author Deepak Kumar

 * @Web http://www.roseindia.net

 * @Email deepak at roseindia.net

 */



public class SessionTestServlet extends HttpServlet {

  MyTestSessionHome testSessionBean;



  public void init(ServletConfig config) throws ServletException{

  //Look up home interface

   try {

     InitialContext ctx = new InitialContext();

     Object objref = ctx.lookup("ejb/test/MyTestSessionBean");

     testSessionBean = (MyTestSessionHome)PortableRemoteObject.narrow(objref, MyTestSessionHome.class);

   } catch (Exception NamingException) {

     NamingException.printStackTrace();

   }





  }



  public void doGet (HttpServletRequest request, 

     HttpServletResponse response) 

     throws ServletException, IOException

  {



    PrintWriter out;

    response.setContentType("text/html");

    String title = "EJB Example";

    out = response.getWriter();



        out.println("");

        out.println("");

	  out.println("Hello World Servlet!");

        out.println("");

        out.println("");

		  out.println("<p align=\"center\"><font size=\"4\" color=\"#000080\">Servlet Calling Session Bean");





    try{

    MyTestSession beanRemote;

	    beanRemote = testSessionBean.create();

	    out.println("<p align=\"center\"> Message from Session Bean is: " + beanRemote.SayHello() + "");	

	    beanRemote.remove();

    }catch(Exception CreateException){

       CreateException.printStackTrace();

    }

		  out.println("<p align=\"center\"><a href=\"javascript:history.back()\">Go to Home");

        out.println("");

        out.println("");





    out.close();

  }



  public void destroy() {

    System.out.println("Destroy");

  }

}





deployment des:
<ejb-jar>



   Example 3

   <display-name>Example 3</display-name>



   <enterprise-beans>



      <!-- Session Beans -->

      

         <display-name>My Test Session Bean</display-name>

         <ejb-name>test/MyTestSession</ejb-name>

         test.session.MyTestSessionHome

         test.session.MyTestSession

         <ejb-class>test.session.MyTestSessionBean</ejb-class>

         <session-type>Stateless</session-type>

         <transaction-type>Container</transaction-type>

      



   </enterprise-beans>



   <assembly-descriptor>



   </assembly-descriptor>



</ejb-jar>

jboss.xml:


   <enterprise-beans>

      
         <ejb-name>test/MyTestSession</ejb-name>
         <jndi-name>ejb/test/MyTestSessionBean</jndi-name>
      

   </enterprise-beans>

   <resource-managers>
   </resource-managers>





View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037419#4037419

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037419



More information about the jboss-user mailing list