• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form values retreive in servlet and passed to EJB

 
saahil sinha
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone please tell me how do i pass the form values retrieved in a servlet to an ejb where the form values will be inserted in a databse.
I need an example code for this.
Also i need to know a good applicaion server to use for J2EE which does not require much of study and can be used quickly.I tried using JBoss but i just canot download the server from the site.
The requirement is urgent so pls help
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you have already written an entity bean to insert data, follow these steps -
  • Use request.getParameter() to access form values in the Servlet.
  • Using InitialContext, lookup home stub for your ejb.
  • Call home.create() which will then call ejbCreate() on your bean.


  • Note that this is just one of many possible approaches. You can use straight JDBC calls instead of entity beans. Similarly you can encapsulate calls to entity bean(s) in a session bean and call session bean methods from the web-tier(Servlet).
    For code examples, just google around for EJB resources and you will find plenty of them.
    App servers come in all shapes and sizes. Sun's J2EE reference implementation is the simplest of all, but has no "smart" capabilities. JBoss, BEA WebLogic and IBM WebSphere are some of the popular ones. Regardless of which one you use, you will have to spend some time understanding the deployment procedures specific to the product.
    Cheers,
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic