0 Replies Latest reply on Jun 22, 2003 10:46 AM by sabar

    pls tell me the steps to create,deploy, run my first j2ee by

    sabar Newbie

      Hi

      i am a newer in j2ee, using eclipse, jboss 3.2.1, lomboz, i started to ceate j2ee application but when make it by lomboz i got error in browse saying :
      HTTP ERROR: 503 Not in context
      RequestURI=/webbouns/servlet/BounsServlet

      here is my code and pls tell me the steps to create them and deploy and run by lomboz

      Bouns.html
      ========




      <H3>Bonus Calculation</H3>


      Enter social security Number:



      Enter Multiplier:










      BounsServlet
      ==========

      import javax.servlet.*;
      import javax.servlet.http.*;
      import java.io.*;
      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import Beans.*;
      public class BonusServlet extends HttpServlet {
      CalcHome homecalc;
      public void init(ServletConfig config)
      throws ServletException{
      //Look up home interface
      try{
      InitialContext ctx = new InitialContext();
      Object objref = ctx.lookup("calcs");
      homecalc =
      (CalcHome)PortableRemoteObject.narrow(
      objref,
      CalcHome.class);
      } catch (Exception NamingException) {
      NamingException.printStackTrace();
      }
      }
      public void doGet (HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
      String socsec = null;
      int multiplier = 0;
      double calc = 0.0;
      PrintWriter out;
      response.setContentType("text/html");
      String title = "EJB Example";
      out = response.getWriter();
      out.println("");
      out.println(title);
      out.println("");
      try{
      Calc theCalculation;
      //Get Multiplier and Social Security Information
      String strMult =
      request.getParameter("MULTIPLIER");
      Integer integerMult = new Integer(strMult);
      multiplier = integerMult.intValue();
      socsec = request.getParameter("SOCSEC");
      //Calculate bonus
      double bonus = 100.00;
      theCalculation = homecalc.create();
      calc =
      theCalculation.calcBonus(multiplier, bonus);
      } catch(Exception CreateException){
      CreateException.printStackTrace();
      }
      //Display Data
      out.println("<H1>Bonus Calculation</H1>");
      out.println("Soc Sec: " + socsec + "");
      out.println("Multiplier: " +
      multiplier + "");
      out.println("Bonus Amount: " + calc + "");
      out.println("");
      out.close();
      }
      public void destroy() {
      System.out.println("Destroy");
      }
      }

      CalcHome
      =======
      package Beans;
      import java.rmi.RemoteException;
      import javax.ejb.CreateException;
      import javax.ejb.EJBHome;
      public interface CalcHome extends EJBHome {
      Calc create() throws CreateException,
      RemoteException;
      }

      Calc
      ====

      package Beans;
      import javax.ejb.EJBObject;
      import java.rmi.RemoteException;
      public interface Calc extends EJBObject {
      public double calcBonus(int multiplier,
      double bonus)
      throws RemoteException;
      }

      CalcBean
      ========

      package Beans;
      import java.rmi.RemoteException;
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;
      public class CalcBean implements SessionBean {
      public double calcBonus(int multiplier,
      double bonus) {
      double calc = (multiplier*bonus);
      return calc;
      }
      //These methods are described in more
      //detail in Lesson 2
      public void ejbCreate() { }
      public void setSessionContext(
      SessionContext ctx) { }
      public void ejbRemove() { }
      public void ejbActivate() { }
      public void ejbPassivate() { }
      public void ejbLoad() { }
      public void ejbStore() { }
      }

      pls tell me the steps to create,deploy, run them by lomboz

      with regards