4 Replies Latest reply on Apr 28, 2006 9:30 AM by francesco vivoli

    Binding to a bean in a jsp page

    Ray Slee Newbie

      I have been following the EJB3 tutorials and from a jsp page I can access an Stateless Session Bean's data when calling the object from a servlet, but when I try and access the bean directly from the jsp I get a 'remote not bound' exception

      for instance I can call from a servlet:

      protected void processRequest( HttpServletRequest request, HttpServletResponse response )
       throws ServletException, IOException
       {
       String actionName = request.getParameter( ACTION_KEY );
       String destinationPage = ERROR_PAGE;
      
       // perform action
       if( VIEW_ITEMS_LIST_ACTION.equals( actionName ) )
       {
       ItemsDAO itemDao = new ItemDAO();
       request.setAttribute( "itemList", itemDao.getItemList() );
       destinationPage = "/itemList.jsp";
       }
      
      

      and then can access the data from the itemList.jsp page, but what I would like to do is manipulate the object directly from the itemList.jsp page as in:

      <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
      <%@ page import="javax.naming.*,
       java.text.*,
       java.lang.*,
       java.util.*,
       com.wsmp.dao.*,
       com.wsmp.dto.*"%>
      <%!
       private ItemDAO itemDao = null;
       public void jspInit ()
       {
       try
       {
       InitialContext ctx = new InitialContext();
       itemDao = (ItemDAO) ctx.lookup("wsmp/ItemDAO/remote");
       }
       catch( Exception e ) { e.printStackTrace(); }
       }
      %>
      
      <html>
      .
      .
      
      


      This lookup fails - what should I do to register the ItemDAO Session Bean for a lookup from a web client? - I know that sounds like a dumb question but I thought that EJB3 obviated the need to register the beans in the web.xml file...